Dev Prakash Sharma has Published 548 Articles

Function to close the window in Tkinter

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 27-Mar-2021 06:27:03

1K+ Views

Whenever we run a tkinter application, it displays a GUI-based window that would have widgets, frames, and other elements. Let us suppose we want to close our application with a function. The destroy() method in Python tkinter is used to terminate the normal execution of the application after the mainloop ... Read More

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

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 27-Mar-2021 06:21:20

15K+ Views

Tkinter windows can be resized automatically by hovering and pulling over the window. 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 to be resized.Example#Import the tkinter library from tkinter import * #Create an ... Read More

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

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 27-Mar-2021 06:20:58

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 ... Read More

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

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 27-Mar-2021 06:19:15

15K+ Views

In order to change the background color and foreground color of a tkinter frame, we can assign different values to the bg and fg parameters in the Frame function.ExampleIn this example, we have created two frames with different background colors.#Import the required libraries from tkinter import * #Create an ... Read More

How do I display tooltips in Tkinter?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 27-Mar-2021 06:10:28

4K+ Views

Tooltips are useful in applications where we need to display some information while hovering on a button.In order to create and display a tooltip, we can use the Balloon property of tkinter.Example#Import the tkinter library from tkinter import * from tkinter.tix import * #Create an instance of tkinter frame ... Read More

How do I handle the window close event in Tkinter?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 27-Mar-2021 06:09:56

7K+ Views

Tkinter provides a custom handler to close the window. It acts as a callback function that the user can run in order to close the window.To close the window using the handler, we can use the destroy() method. It closes the window abruptly after calling it in any function or ... Read More

How do I insert a JPEG image into a Python Tkinter window?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 27-Mar-2021 06:08:27

3K+ Views

Python provides the Pillow (PIL) package to support, process, and display the images in tkinter applications. A Tkinter application generally supports image files such as, ppm, png, and gif.Let us suppose we want to embed and display a JPEG or JPG image in our application.Tkinter Label widgets are generally used ... Read More

How do I set a minimum window size in Tkinter?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 27-Mar-2021 06:08:00

3K+ Views

A Tkinter window can be initialized after running the application. Generally, the width and the height of the window is resizable which can be minimized.In order to set the window size to its minimum value, assign the value of width and height in minsize(height, width) method. The method can be ... Read More

How to attach a Scrollbar to a Text widget in Tkinter?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 27-Mar-2021 06:07:30

3K+ Views

Tkinter Text widget is used to accept multiline user Input. It is similar to Entry Widget but the only difference is that Text widget supports multiple line texts. In order to create a Text widget, we have to instantiate a text object.Adding multiple texts will require to add the ScrollBar. ... Read More

How to bundle a Python Tkinter application including dependencies?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 26-Mar-2021 11:21:10

891 Views

Let us suppose we have created a tkinter application and now, we want to bundle the standalone application to make it portable and executable. We can use different Python packages that support various functionality to bundle the whole application code into an executable installer. These packages compress the code and ... Read More

Advertisements