Found 310 Articles for GUI-Programming

Python Tkinter – How to display a table editor in a text widget?

Dev Prakash Sharma
Updated on 22-Dec-2021 11:12:08

2K+ Views

Tkinter is a Python-based GUI toolkit that is used to create fullfledged desktop applications. Tkinter has a variety of modules and class libraries to help developers create userfriendly applications quickly and easily.The Text widget in tkinter provides users a way to create a text editor that accepts multiline user-input. You can configure and customize its properties and attributes. Suppose you want to represent your 2-dimensional data in a table using only the Text widget. To create a table in a Text widget, we have to first create a 2-d array consisting of data that needs to be displayed in the ... Read More

How to disable an Entry widget in Tkinter?

Dev Prakash Sharma
Updated on 22-Dec-2021 11:10:31

14K+ Views

Tkinter Entry widget accepts single line user-input in an entry field. You can customize the width, background color and size of the entry widget based on the need of your application.Let us assume that in a particular application, we want to disable an Entry widget. To disable the Entry widget, use state='disabled' property in the constructor. Disabling the Entry widget will not allow users to edit and add values to it.ExampleLet us understand this with an example. In this example, we will create an Entry widget using the constructor Entry(master, **options) and a Button to disable it. The function disable_entry() ... Read More

How to resize an Entry Box by height in Tkinter?

Dev Prakash Sharma
Updated on 04-Oct-2023 20:49:37

27K+ Views

An Entry widget in a Tkinter application supports singleline user inputs. You can configure the size of an Entry widget such as its width using the width property. However, tkinter has no height property to set the height of an Entry widget. To set the height, you can use the font('font_name', font-size) property. The font size of the text in an Entry widget always works as a height of the Entry widget.ExampleLet us take an example to understand this more clearly. Follow the steps given below −Import the required librariesCreate an Entry widget, set its width and height by specifying ... Read More

How to add a column to a Tkinter TreeView widget?

Dev Prakash Sharma
Updated on 22-Dec-2021 11:06:19

3K+ Views

Tkinter TreeView widget is used to present data in a hierarchical manner in the form of rows and columns. To create a Treeview widget, you have to first create a constructor of Treeview(master, column, show='headings') widget. Here, you can specify the list of columns and pass the value to the column parameter that you want to include in the table.The indexing of data in the Treeview widget starts from 0. Therefore, to avoid counting the first column, we need to use the show=heading parameter. Let us create an application to show a table with two columns "ID" and "Company" of ... Read More

How to temporarily remove a Tkinter widget without using just .place?

Dev Prakash Sharma
Updated on 22-Dec-2021 11:04:39

761 Views

To place Tkinter widgets inside a Frame or a Canvas, you can use various geometry managers. The geometry manager allows you to set the layout of the widget and how they will appear in the tkinter window. The place() method is one of the simplest geometry managers which is used to set the position of a widget relatively and explicitly to the window. We can also use the place() method to separate the widgets from each other, as it supports the relative property to position the widget with respect to others.In some cases, if you want to temporarily remove a ... Read More

How to center a label in a frame of fixed size in Tkinter?

Dev Prakash Sharma
Updated on 22-Dec-2021 11:02:47

12K+ Views

Tkinter is a GUI toolkit in Python used to build desktopbased applications. Tkinter provides several widget functionalities and class libraries to develop various components of an application. The Frame widget is one of the widgets that works similar to the standard tkinter default window. You can place as many widgets as you want in a Frame widget. You can also customize the properties like resizing the frame, its background color and also the layout using geometry managers.ExampleSuppose we need to create an application in which we want to create a Label widget inside a fixedsize frame. The Label widget must ... Read More

How to display a tkinter application in fullscreen on macOS?

Dev Prakash Sharma
Updated on 28-Dec-2021 07:24:57

699 Views

Tkinter is a Python GUI toolkit, which is widely known for developing full-fledged functional desktop applications. Tkinter provides many built-in libraries, widgets, and modules to develop any kind of application. You can use the factory and class library functions to implement additional functionality of the application.Since Tkinter is a cross-platform GUI library, an application programmed in Windows can run in macOS as well as Linux devices. However, some functions don't support cross-platform ability for which you have to refer to the additional factory method or function specified in the documentation.ExampleFor example, if we want to display a tkinter application in ... Read More

Ask a user to select a folder to read the files in Python

Dev Prakash Sharma
Updated on 22-Dec-2021 10:57:52

8K+ Views

If you have ever wondered how the dialogboxes work in a Python application, then you probably end up hearing the filedialog module in Tkinter. The filedialog module contains a number of built-in functions which can be used to display various types of dialogs for dealing with files in the system.In most cases, we use the filedialog.askopenfilename() function to ask the user to browse and open a file from the system. Based on the selection of the filetype, the script is programmed to perform write or read operation.Once a file is opened, you can use the open(file, 'mode') function to open ... Read More

Get the value from a Tkinter scale and put it into a Label

Dev Prakash Sharma
Updated on 22-Dec-2021 10:55:40

2K+ Views

The Scale widget in tkinter allows you to create a visual scale slider object in your application which is used to specify the value using a specific scale. To implement the Scale object, you have to first create a constructor of Scale(root, **options). Here you can specify the properties and attributes of Scale such as command, background, label, length, orient, etc.Since the Scale widget is used to select specific values by dragging the slider, we can get the current value of the scale in a label widget. To retrieve the value of the Scale, use the get() method that returns ... Read More

How to get a string from a tkinter filedialog in Python 3?

Dev Prakash Sharma
Updated on 22-Dec-2021 10:53:38

875 Views

To interact with the filesystem in a tkinter application, you can use the Tkinter filedialog module. It provides a way to deal with the files in the system. The filedialog module offers many built-in functions to help developers create a variety of file dialogs for the application. You can use any of the filedialog functions in order to implement a dialog in your application.The most commonly used function is filedialog.askopenfilename() which generally creates a dialog asking the user to open a file in the given program interface.ExampleSuppose we want to get a string or the filename which we open using ... Read More

Advertisements