Found 310 Articles for GUI-Programming

How do I change the overall theme of a tkinter application?

Dev Prakash Sharma
Updated on 08-Jun-2021 09:50:02

2K+ Views

The ttk themed widget in Tkinter is introduced to design the external properties and styles of a widget in application. The ttk uses Tcl/Tk interpreter to give the user access to the interface that has many inbuilt attributes and features useful for any widget or application. Now, if we compare Ttk themes with Tcl themes, there are lots of variations in it.Ttk generally supports only a few themes which are as follows −winnativeclamaltdefaultclassicvistaxpnativeIn order to change the overall theme of a tkinter application, we have to use the style.theme_use(theme_name) function.Example# Import the required libraries in tkinter from tkinter import * ... Read More

Programmatically opening URLs in a web browser in Python (tkinter)

Dev Prakash Sharma
Updated on 08-Jun-2021 09:47:09

494 Views

Python has a rich library of extensions and modules which are used for multiple purposes. To work with web-based content, Python provides a webbrowser module. The module creates an environment which enables the user to display web-based content in the application. To work with webbrowser, you have to make sure that it is installed in your local machine.import webbrowserIf the module is not available in your environment, then you can install it using the following command −pip install webbrowserExampleUsing the webbrowser module in our program, we will open an URL in our web browser. To open the URL in a ... Read More

How to bind to shift+tab in Tkinter?

Dev Prakash Sharma
Updated on 08-Jun-2021 09:43:00

1K+ Views

Tkinter Events are very useful for any application where we need to perform a certain task or action. In Tkinter, the events are generally created by defining the function which contains the piece of code and the logic for the certain event. To call the event, we generally bind the Event with some Keys or a Button widget. The bind function takes two parameters ('', callback) which enable the button to trigger the event.Using the same approach in the following example, we will trigger a popup message by pressing the key combination .Example# Import the required libraries from tkinter import ... Read More

Change the color of "tab header" in ttk.Notebook (tkinter)

Dev Prakash Sharma
Updated on 08-Jun-2021 09:40:58

5K+ Views

Tabs are very useful for a multipurpose GUI application. It helps to isolate the several tasks or processes within the application in the form of tabs. Tabs are very useful for processing multiple tasks at a time. With the help of Tkinter Notebook widget, we can create Tabs in our tkinter application.To configure the property or style of the tabs, we must have to use a ttk themed widget. The ttk themed widget helps to style any widget present in the application. To configure the background color of the tab, you can use ttk 'default' theme along with passing 'TNotebook.Tab' ... Read More

How do you overlap widgets/frames in Python tkinter?

Dev Prakash Sharma
Updated on 08-Jun-2021 09:39:47

4K+ Views

There are three general ways through which we can align and position a particular widget in a Tkinter application. Let us suppose that we want to overlap two or more widgets or frames one on another, then we can use place() geometry manager. What place() geometry manager does is that it lines up the widget in rows and columns of a grid. We can certainly overlap the widget by providing the same coordinate in each.Example# Import the required libraries from tkinter import * from tkinter import ttk # Create an instance of tkinter frame win = Tk() # ... Read More

How to edit the style of a heading in Treeview (Python ttk)?

Dev Prakash Sharma
Updated on 08-Jun-2021 09:37:56

7K+ Views

Python Treeview widget is introduced for creating a Table look-like GUI in application. It includes many inbuilt features and functions which can be used to configure the properties. However, to configure the style of a tkinter widget, we generally refer to use ttk themed widget. This allows you to edit the style such as background color, foreground color, and other properties of the treeview widget as well.ExampleIn this example, we will create an instance of the ttk style widget and then configure the style of heading by passing 'Treeview.Heading' as the style parameter.# Import the required libraries from tkinter import ... Read More

How to display LaTex in real time in a text box in Tkinter?

Dev Prakash Sharma
Updated on 08-Jun-2021 09:36:26

2K+ Views

Python Matplotlib library is useful in applications where we need to visualize the data points and draw graphs and plots to analyze the data. Let us suppose that we want to create a tkinter application where we can process LaTex syntax.LaTex syntax is used for preparing scientific documentation such as, formulae, scientific notations, mathematical characters, and punctuations. To prepare the application, we are required to use matplotlib and TkAgg (backend API for Matplotlib in Tkinter) modules. The following steps are used to structure the application functions and widgets, Import the required libraries such as Matplotlib, Tkinter, Ttk (for styling the ... Read More

How to show webcam in TkInter Window?

Dev Prakash Sharma
Updated on 08-Jun-2021 09:33:33

7K+ Views

Python libraries are independent and thus they all can be used for different purposes while building a particular featured application. In this example, we will build an application using OpenCV and Tkinter library. OpenCV is a Python library that is used to work with Computer Vision and other artificial artifacts. Using the OpenCV module, we have to show the webcam in a tkinter window.To create the application, you are required to install open-cv in your local machine and make sure that Python Pillow package is pre-installed. You can install these packages by typing the following commands, pip install open-cv pip ... Read More

How can I vary a shape's alpha with Tkinter?

Dev Prakash Sharma
Updated on 08-Jun-2021 09:31:31

1K+ Views

The Canvas widget is one of the multilateral widgets in tkinter library which is used to provide graphics for any application. It can be used to draw shapes, images, animating objects or any complex visuals. The alpha property of the shape defines that if we give the alpha value to any shape, then it must have some transparency behaviour with respect to its parent window.To define the alpha property, we have to assume that every shape have some colors in it and whenever we provide an alpha value to a shape, then it must be converted into an Image. The ... Read More

How to handle a Button click event in Tkinter?

Dev Prakash Sharma
Updated on 14-Sep-2023 21:06:55

31K+ Views

Sometimes, handling events in a Tkinter application can become a daunting task for us. We have to manage the action and events which need to be executed at the time of running the application. The Button widget is useful for handling such events. We can use Button widget to perform a certain task or event by passing the callback in the command.While giving the command to the Button widget, we can have an optional lambda or anonymous functions which interpret to ignore any errors in the program. These are just like a general function but they don't have any function ... Read More

Advertisements