GUI-Programming Articles

Page 22 of 25

How to use Unicode and Special Characters in Tkinter?

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

Sometimes we need to add Unicode and special characters in our Tkinter application. We can add Unicode characters in our labels or widgets by concatenating the signature as u'\u'. You can find the list of all Unicode characters from here. Basic Unicode Character Example In this example, we will add a Unicode character in the button widget ? # Import the required Libraries from tkinter import * # Create an instance of tkinter frame win = Tk() win.geometry("700x200") # Create a button with Unicode character Button(win, text='Click' + u'\u01CF', font=('Poppins bold', 10)).pack(pady=20) # ...

Read More

How to use Thread in Tkinter Python?

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

With Tkinter, we can call multiple functions simultaneously using Threading. Threading provides asynchronous execution of functions in an application, preventing the GUI from freezing during long-running operations. To use threading in Python, we import the threading module. The Thread() function allows us to execute functions in separate threads, keeping the main GUI thread responsive. Basic Threading Example Let's create a thread that sleeps for 5 seconds while keeping the GUI responsive ? import tkinter as tk import time import threading # Create the main window win = tk.Tk() win.geometry("400x200") win.title("Threading Example") # Create ...

Read More

How to speed up scrolling responsiveness when displaying lots of text in Tkinter?

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

When displaying large amounts of text in Tkinter, scrolling can become sluggish and unresponsive. This happens because Tkinter tries to render all content at once, which can overwhelm the interface when dealing with files containing thousands of lines. To improve scrolling responsiveness with large text files, we can use a Scrollbar widget combined with a Listbox or Text widget. The scrollbar allows users to navigate through content efficiently without loading everything into memory simultaneously. Basic Implementation with Listbox Here's how to create a responsive scrollable text display using a Listbox with a vertical scrollbar: import ...

Read More

How to return a JSON object from a Python function in Tkinter?

Sarika Singh
Sarika Singh
Updated on 25-Mar-2026 3K+ Views

JSON (JavaScript Object Notation) is a lightweight data format for exchanging data between different programming languages. In Python, you can work with JSON using the built-in json module, which provides methods to convert Python objects to JSON strings and vice versa. When working with Python functions, you often need to return structured data as JSON objects. This is particularly useful in web applications, APIs, and data processing tasks where standardized data exchange is important. Understanding JSON Conversion Python converts objects to JSON through serialization − the process of transforming Python data structures into a JSON-compatible string format. ...

Read More

How to remove text from a label in Python?

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

Tkinter is Python's standard GUI library for creating desktop applications. Sometimes you need to dynamically remove or clear text from a Label widget during runtime. To remove text from a label, we can modify the Label's text attribute using the config() method. Let's create a simple application with a button that removes text from a label. Basic Example Here's how to create a label with text and a button to remove that text ? # Import Tkinter Library from tkinter import * # Create an instance of tkinter frame win = Tk() # ...

Read More

How to remove multiple selected items in the listbox in Tkinter?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 898 Views

When working with Tkinter's Listbox widget, you might need to remove multiple selected items. This requires setting the selection mode to allow multiple selections and implementing proper deletion logic. Setting Up Multiple Selection To enable multiple item selection in a Listbox, use selectmode=MULTIPLE. This allows users to select multiple items by clicking while holding Ctrl or Shift. Example Here's a complete example showing how to remove multiple selected items from a Listbox ? # Import the required libraries from tkinter import * # Create an instance of tkinter frame or window win = ...

Read More

How to remove empty tags using BeautifulSoup in Python?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 953 Views

BeautifulSoup is a Python library that pulls out data from HTML and XML files. Using BeautifulSoup, we can remove empty tags present in HTML or XML documents and convert the data into clean, human-readable format. First, install the BeautifulSoup library using: pip install beautifulsoup4 Basic Example − Removing Empty Tags Here's how to identify and remove empty tags from an HTML document ? from bs4 import BeautifulSoup # HTML document with empty tags html_document = """ Python is an interpreted, high-level programming language. ...

Read More

How to open External Programs using Tkinter?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 679 Views

Sometimes, while creating an application, we need to interact with external programs and applications. In order to interact with the system's applications and programs, we have to use os Module in python. In this article, we will see how we can interact with external programs and open files using the OS module in Python. First, we will define a function that will open the chosen file using the filedialog library in Python. Then, we will print the path and open the file using the os module. Example Let's create a Tkinter application that allows users to ...

Read More

How to make the Tkinter text widget read only?

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

In Tkinter, you can make a text widget read-only by setting its state configuration to DISABLED. This prevents users from editing the content while keeping it visible and readable. Making Text Widget Read-Only Use the config() method to change the state of a text widget ? from tkinter import * # Create an instance of window win = Tk() win.geometry("700x400") win.title("Read-Only Text Widget") def disable_button(): text.config(state=DISABLED) def enable_button(): text.config(state=NORMAL) # Label Label(win, text="Type Something", font=('Helvetica bold', 25), ...

Read More

How to get the Tkinter widget's current x and y coordinates?

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

Tkinter is widely used to create GUI-based applications. It provides various widgets including buttons, text boxes, and labels. We can customize the position of widgets and retrieve their coordinates on the tkinter frame using geometry methods. To get the actual coordinates of a widget, we can use the geometry methods available in tkinter's library. The winfo_rootx() and winfo_rooty() functions return the actual coordinates of the widget with respect to the root window. Syntax widget.winfo_rootx() # Returns x-coordinate widget.winfo_rooty() # Returns y-coordinate Example Here's how to get the current coordinates of different ...

Read More
Showing 211–220 of 242 articles
Advertisements