GUI-Programming Articles

Page 9 of 25

How do I print and have user input in a text box in Tkinter?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 26-Mar-2026 9K+ Views

Tkinter's Text widget allows you to create multi-line text input areas and display information. You can retrieve user input using the get() method and display content using insert(). Here's how to create an interactive text box application. Basic Text Widget Example This example creates a text box where users can type, and clicking "Print" displays the content in a label ? # Import the required library from tkinter import * from tkinter import ttk # Create an instance of tkinter frame win = Tk() # Set the geometry win.geometry("700x350") win.title("Text Widget Example") def ...

Read More

How to get an element to stick to the bottom-right corner in Tkinter?

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

Tkinter has many inbuilt features, functions, and methods that we can use to construct the GUI of an application. It is necessary to know how we can set the position of a particular widget in the application so that it becomes responsive in nature. Tkinter also provides geometry managers through which we can set the position of elements and widgets. The Place geometry manager is used for configuring the position of complex widgets with precise control over their placement. Using place() with anchor Property To position a widget at the bottom-right corner, we can use the place() ...

Read More

How to align text to the right in ttk Treeview widget?

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

The Treeview widget displays data in a hierarchical table structure with rows and columns. By default, text in Treeview columns is left-aligned, but you can control alignment using the anchor property. To align text to the right in a ttk Treeview widget, use the anchor parameter with the value "E" (East) when configuring columns. This property controls the position of text within each column cell. Syntax tree.column("column_id", anchor="E") Anchor Values The anchor parameter accepts the following values ? Value Alignment Description "W" Left West (default) "CENTER" ...

Read More

How to make Tkinter Window appear in the taskbar?

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

A System Tray application allows your Tkinter window to minimize to the taskbar instead of completely closing. When minimized, the application continues running in the background and can be accessed through a system tray icon. To create a System Tray icon for a Tkinter application, we use the pystray module in Python. This module provides built-in functions to configure the system tray icon and handle user interactions. Installation First, install the required module using pip ? pip install pystray Creating a System Tray Application Follow these steps to create a system tray ...

Read More

How to change the background color of a Treeview in Tkinter?

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

The Treeview widget in Tkinter is designed to display data in a hierarchical structure, such as directories, subdirectories, or files. You can customize its appearance by changing the background color using styling methods. Understanding Treeview Styling Unlike basic Tkinter widgets, the Treeview widget requires the ttk.Style() class to change its background color. The background property is controlled through style configuration ? Example − Changing Treeview Background Color import tkinter as tk from tkinter import ttk # Create main window root = tk.Tk() root.title("Treeview Background Color") root.geometry("600x400") # Create a style object style = ...

Read More

How to clear a Tkinter ListBox?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 26-Mar-2026 14K+ Views

The Tkinter ListBox widget displays a list of selectable items with scrolling capability. To clear all items from a ListBox, use the delete(0, END) method. You can also delete individual items using delete() with specific indices. Basic ListBox Clearing The delete() method removes items from the ListBox. Use 0 as the start index and END to clear all items ? from tkinter import * from tkinter import ttk # Create main window win = Tk() win.geometry("500x300") win.title("Clear ListBox Example") # Create ListBox widget listbox = Listbox(win, width=40, height=8, font=('Arial', 12)) listbox.pack(pady=20) # Add ...

Read More

How can I set the row height in Tkinter TreeView?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 26-Mar-2026 10K+ Views

The Treeview widget in Tkinter provides a way to display data in a hierarchical table structure. You can customize the appearance of the Treeview, including setting custom row heights using the ttk.Style configuration. To set the row height in a Tkinter Treeview, you need to use the ttk.Style() class and configure the rowheight property. This property adds internal padding to each row, making them taller or shorter as needed. Syntax style = ttk.Style() style.configure('Treeview', rowheight=height_value) Example Here's how to create a Treeview with custom row height ? # Import the required ...

Read More

How do I use Window Manager (wm) attributes in Tkinter?

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

The Window Manager (wm) is a toolkit available in Tcl/Tk that provides control over window appearance and behavior. In Tkinter, you can access these features using the wm_attributes() method to modify properties like transparency, window state, and interaction behavior. Basic Window Manager Attributes The wm_attributes() method accepts attribute-value pairs to control window properties. Here are the most commonly used attributes − Example # Import the required library from tkinter import * # Create an instance of tkinter frame win = Tk() # Set the geometry win.geometry("700x350") Label(win, text="This window has special attributes.", ...

Read More

How to add a separator in Menu item in Tkinter?

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

The Tkinter Menu widget is used to create dropdown menus in applications. Menu widgets allow users to select items and execute specific tasks. A common feature in menus is the visual separator − a dotted line that groups related menu items together for better organization. To add a separator between menu items, Tkinter provides the add_separator() method. This creates a horizontal line that visually separates different groups of menu items, making the interface more intuitive and organized. Syntax menu.add_separator() This method takes no parameters and simply adds a visual separator line at the current ...

Read More

How to draw a dot on a canvas on a click event in Tkinter Python?

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

Consider a case for creating a GUI application such that when we click on the window with a mouse button, it stores the coordinates and draws a dot. Tkinter provides events that allow the user to bind the keys or buttons with the functions. To draw a dot on click event, we can follow these general steps − Create a canvas widget and pack it to display in the window. Define a function draw_dot() that works as the event when the user does the click event. Bind the ...

Read More
Showing 81–90 of 242 articles
« Prev 1 7 8 9 10 11 25 Next »
Advertisements