Tkinter Articles

Page 22 of 46

What is the best way to show data in a table in Tkinter?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 7K+ Views

When building Tkinter applications, displaying data in tables is a common requirement. Tkinter provides the Treeview widget from the ttk module, which is the best way to create professional-looking tables with columns, headers, and structured data. The Treeview widget can display hierarchical data (like file systems) or flat tabular data (like spreadsheets). For table display, we use it in "headings" mode to show column headers without the tree structure. Basic Table Implementation Here's how to create a student data table using Treeview ? import tkinter as tk from tkinter import ttk # Create main ...

Read More

How to create a resizable Windows without title bar in Tkinter?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 5K+ Views

To create a tkinter window without title bar, we can use overrideredirect(boolean) property which disables the navigation panel from the top of the tkinter window. However, it doesn't allow the user to resize the window instantly. If we are required to create a resizable window without the title bar programmatically, then we can use Sizegrip(parent) widget in Tkinter. The Sizegrip widget adds extendibility to the application that allows users to pull and resize the main window. To work with Sizegrip widget, we have to bind the mouse buttons and a function that resizes the window whenever we pull the ...

Read More

How to switch between two frames in Tkinter?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 11K+ Views

In GUI applications, you often need multiple screens to organize different sections of your program. Tkinter allows you to create separate Frame widgets that can be switched dynamically to show different content within the same window. A Frame widget acts as a container to group related widgets together. By creating multiple frames and controlling their visibility, you can implement screen navigation in your Tkinter application. Basic Frame Switching Example Let's create two frames — a greeting frame and an order frame — with buttons to switch between them − # Import the required libraries from ...

Read More

How to Move an Image in Tkinter canvas with Arrow Keys?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 5K+ Views

Tkinter Canvas widget is one of the versatile widgets in the Tkinter library. It is used to create different shapes, images, and animating objects. We can provide a dynamic attribute to the image defined in a Canvas widget by using the move() method. Define the image and the coordinates as a parameter in the move(image, x, y) method to move the Image in the Canvas. We declare images globally in order to track the Image location in the Canvas. Steps to Move Image with Arrow Keys We can follow these steps to make our image movable within ...

Read More

How to move a Tkinter canvas with Mouse?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 6K+ Views

Tkinter Canvas widget is one of the versatile widgets in the Tkinter library. It is used to create different shapes, images, and animating objects. We can move images in a particular direction on the Canvas widget using the move() method. Define the image and the coordinates as a parameter in the move(Image, x, y) method to move the object in the Canvas. We declare images globally in order to move or change the position. We can follow these steps to allow our image to move within the canvas: First, define the Canvas widget and add images ...

Read More

How to display a Listbox with columns using Tkinter?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 7K+ Views

The Tkinter Treeview widget is the standard way to create a listbox with columns in Python GUI applications. Unlike a basic Listbox, Treeview can display data in tabular format with multiple columns, headers, and sorting capabilities. Creating a Treeview Widget The Treeview widget is constructed using ttk.Treeview(parent, columns, **options). The show='headings' parameter hides the tree structure and displays only the columns ? import tkinter as tk from tkinter import ttk # Create main window window = tk.Tk() window.title("Listbox with Columns") window.geometry("700x350") # Create Treeview widget with 3 columns tree = ttk.Treeview(window, columns=("c1", "c2", "c3"), ...

Read More

How to open multiple filenames in Tkinter and add the file names to a list?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 4K+ Views

To open multiple files in a Tkinter application and add their names to a list, we use the tkinter.filedialog package. This creates a dialog box to interact with external files on the system. Importing the Required Module First, import the filedialog module ? import tkinter.filedialog as fd Using askopenfilenames() Function The askopenfilenames() function opens a file explorer window that allows users to select multiple files. It returns a tuple of selected file paths. Syntax fd.askopenfilenames(parent=None, title="Open files", **options) Complete Example Here's a complete example that opens multiple ...

Read More

How to create a directly-executable cross-platform GUI app using Python(Tkinter)?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 2K+ Views

Python is a programming language that can create cross-platform applications for Microsoft Windows, Mac OS, and Linux. To build GUI applications, we use the Tkinter library, and to convert them into executable files, we use packaging tools. Available Tools for Creating Executables Different tools are available for different operating systems − For Windows executables − PyInstaller, py2exe For Linux executables − Freeze For Mac executables − py2app PyInstaller is the most popular choice as it works across all platforms. Installing PyInstaller First, install ...

Read More

How to read multiple text files from a folder in Python?(Tkinter)

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 7K+ Views

Python provides powerful file handling capabilities through its built-in modules. The OS module allows you to interact with the operating system and work with files and directories efficiently. When you need to read multiple text files from a specific folder, you can use the OS module to iterate through directory contents and process only the files with desired extensions. Required Steps Import the OS module Define the directory path containing text files Create a function to read file contents Iterate through files and filter by extension Read and display the contents Example Here's ...

Read More

How do I get the background color of a Tkinter Canvas widget?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 3K+ Views

Tkinter Canvas widget is used for drawing shapes, images and complex visuals in GUI applications. You can configure its properties like background color using the configure() method or by passing attributes during creation. To get the background color of a Canvas widget, you can use the dictionary-style access canvas["background"] or the cget() method. This is useful when you want to inherit the canvas background color in other widgets or parts of your application. Using Dictionary-Style Access The most common way to get the background color ? import tkinter as tk # Create main window ...

Read More
Showing 211–220 of 459 articles
« Prev 1 20 21 22 23 24 46 Next »
Advertisements