Server Side Programming Articles

Page 399 of 2109

Difference between tkinter and Tkinter

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

The main difference between Tkinter and tkinter is the Python version compatibility. Tkinter (capital T) was used in Python 2, while tkinter (lowercase t) is used in Python 3 and later versions. Python 2 vs Python 3 Import Syntax In Python 2, the tkinter module was named with a capital T ? from Tkinter import * In Python 3 and later, the module name uses lowercase ? from tkinter import * Example: Python 3 Error with Capital T If you try to use the old Python 2 syntax in ...

Read More

Display message when hovering over something with mouse cursor in Tkinter Python

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

Let us suppose we want to create an application where we want to add some description on Tkinter widgets such that it displays tooltip text while hovering on the button widget. It can be achieved by adding a tooltip or popup. Tooltips are useful in applications where User Interaction is required. We can define the tooltip by instantiating the constructor of Balloon(win) from tkinter.tix. After that, we can bind the button with the tooltip message that applies on the widget. Using tkinter.tix for Tooltips The tkinter.tix module provides the Balloon widget for creating tooltips. Here's how to ...

Read More

Draw a circle in using Tkinter Python

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

Tkinter Canvas widget provides built-in methods for creating various shapes including circles, rectangles, triangles, and freeform shapes. To draw a circle, we use the create_oval() method with specific coordinates. Syntax The basic syntax for creating a circle using create_oval() method is ? canvas.create_oval(x0, y0, x1, y1, options) Parameters x0, y0 ? Top-left corner coordinates of the bounding rectangle x1, y1 ? Bottom-right corner coordinates of the bounding rectangle options ? Additional styling options like fill, outline, width Example − Basic Circle Here's how to create a simple circle using ...

Read More

How can I create a dropdown menu from a List in Tkinter?

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

Creating a dropdown menu in Tkinter is simple using the OptionMenu widget. This widget allows users to select from a predefined list of options through a dropdown interface. Basic Dropdown Menu To create a dropdown menu, use OptionMenu(parent, variable, *values) where the variable stores the selected value − from tkinter import * # Create main window win = Tk() win.geometry("400x200") win.title("Dropdown Menu Example") # Create StringVar to store selected value selected_language = StringVar() selected_language.set("Select Any Language") # Create dropdown menu languages = ["C++", "Java", "Python", "JavaScript", "Rust", "GoLang"] dropdown = OptionMenu(win, selected_language, *languages) ...

Read More

How can I prevent a window from being resized with Tkinter?

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

Tkinter windows can be resized automatically by hovering and pulling over the window borders. We can disable the resizable property using the resizable(boolean value) method. We will pass False value to this method which will disable the window from being resized. Example Here's how to create a non-resizable Tkinter window − # Import the tkinter library from tkinter import * # Create an instance of tkinter frame win = Tk() # Set the geometry win.geometry("650x250") Label(win, text="Hello World", font=('Times New Roman bold', 20)).pack(pady=20) # Make the window non-resizable win.resizable(False, False) win.mainloop() ...

Read More

How do I bind the enter key to a function in Tkinter?

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

Pressing a key and handling some operation with the key is an event that can be triggered through a button. We can bind the key event using the binding method in a tkinter application. Whenever the key will be triggered, it will call a handler that will raise the specific operation for the key event. If we want to trigger the Enter key with the bind function, we will use the bind('', Handler) method. For Enter Key, we use bind('', Handler) function. Basic Enter Key Binding Here's a simple example that demonstrates binding the Enter key ...

Read More

How do I change button size in Python Tkinter?

SaiKrishna Tavva
SaiKrishna Tavva
Updated on 25-Mar-2026 54K+ Views

To change the size of Tkinter Button in Python's Tkinter library, we can use the width and height options of the Button widget in terms of text units (characters). Common Approaches We can change button size in Python Tkinter using several methods ? Using Width and Height − Set the width and height properties to determine button size in text units for text buttons. Adjusting Padding − Use padx and pady properties ...

Read More

How do I change the background of a Frame in Tkinter?

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

In Tkinter, you can change the background color of a Frame by setting the bg parameter. You can also modify the foreground color using the fg parameter for text elements within the frame. Basic Syntax The basic syntax for creating a Frame with a custom background color is ? frame = Frame(parent, bg="color_name") # or frame = Frame(parent, background="color_name") Example: Creating Frames with Different Background Colors Here's how to create multiple frames with different background colors ? from tkinter import * # Create an instance of tkinter window win = ...

Read More

How do I display tooltips in Tkinter?

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

Tooltips are helpful UI elements that display additional information when users hover over widgets. In Tkinter, we can create tooltips using the Balloon class from tkinter.tix module. Using tkinter.tix.Balloon The Balloon class provides an easy way to add tooltips to any Tkinter widget − # Import the tkinter library from tkinter import * from tkinter.tix import * # Create an instance of tkinter frame win = Tk() # Set the geometry win.geometry("600x450") # Create a tooltip tip = Balloon(win) # Create a Button widget my_button = Button(win, text="Hover Me") my_button.pack(pady=20) # Bind ...

Read More

How do I handle the window close event in Tkinter?

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

Tkinter provides several ways to handle window close events. You can use the destroy() method directly or create custom close handlers for better control over the closing process. Using destroy() Method Directly The simplest approach is to pass destroy() directly to a widget's command parameter ? # Importing the required library from tkinter import * # Create an instance of tkinter frame or window win = Tk() # Set the geometry win.geometry("600x400") # Create a button and pass destroy method directly close_button = Button(win, text="Close Window", font=('Helvetica bold', 20), ...

Read More
Showing 3981–3990 of 21,090 articles
« Prev 1 397 398 399 400 401 2109 Next »
Advertisements