Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 1224 of 3363
18K+ Views
Tkinter provides a way to bind the widget to perform certain operations. These operations are defined in a function that can be called by a particular widget. The bind(, function()) method is used to bind the keyboard key to handle such operations. We can also bind a particular key to handle certain events for the button widget.Example#Import tkinter library from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame or window win = Tk() #Set the geometry of tkinter frame win.geometry("750x250") def callback(): Label(win, text="Hello World!", font=('Georgia 20 bold')).pack(pady=4) #Create a Label ... Read More
4K+ Views
Images are very useful objects in any application. We can process Images in a Tkinter application using the Pillow or PIL package in Python. There are several built-in functions such as loading an image, extracting an image, configuring the image pane, etc.ExampleIn this example, we will add by asking the user to select an image from a dialog box and then, display it using the Label widget.#Import the Tkinter library from tkinter import * from tkinter import ttk from tkinter import filedialog from PIL import Image, ImageTk #Create an instance of Tkinter frame win= Tk() #Define the geometry win.geometry("750x350") win.title("Image ... Read More
3K+ Views
Let us assume that we want to check if a particular widget has a focused set or not. The only way to check the widget focus is to use the utility method focus_get(). It returns the object containing the widget’s information which is currently focused on, during the program’s execution. We will use the focus_get() method to find the active widget during our program’s execution.ExampleIn this example, we have created an Entry widget that will get its focus when we press the key. The focus_get() method will return the current widget’s information which is active.#Import the Tkinter library from ... Read More
8K+ Views
Callback functions in Tkinter are generally used to handle a specific event happening in a widget. We can add an event callback function to the Entry widget whenever it gets modified. We will create an event callback function by specifying the variable that stores the user input. By using the trace("mode", lambda variable, variable: callback()) method with the variable, we can trace the input on the Label widget in the window.Example#Import the Tkinter library from tkinter import * #Create an instance of Tkinter frame win= Tk() #Define the geometry win.geometry("750x250") def callback(var): content= var.get() Label(win, text=content).pack() #Create an ... Read More
3K+ Views
There are times when a user wants to insert the information like Name, contact number, Email, address, etc. Tkinter has a simple way to handle these types of inputs through its Entry widgets. Tkinter Entry widgets can be styled using the ttk package.To change other properties of the Entry widgets such as font properties, text-size, and font-style, we can use the font(‘font-family font-size font-style’) attribute. We can specify the font property in the entry constructor.Example#Import tkinter library from tkinter import * from tkinter import ttk #Create an instance of tkinter frame or window win= Tk() #Set the geometry of tkinter ... Read More
4K+ Views
In this example, we will see how to resize a tkinter window using the geometry manager. Tkinter geometry manager is generally used to configure the width and height of a tkinter window.The geometry(width, height)method takes width and height as instances and resizes the window accordingly. We can also define the position of the tkinter window by adding geometry(width x height, X, Y) where x and y are horizontal and vertical positions of the window.Example#Import tkinter library from tkinter import * from tkinter import ttk #Create an instance of tkinter frame or window win= Tk() #Set the geometry of tkinter frame ... Read More
13K+ Views
Let us suppose that for a particular application, we want to retrieve the button value by its name. In such cases, we can use the .cget() function. Every tkinter widget supports the .cget() function, as it can be used to retrieve the widget configuration such as value or name.ExampleIn this particular example, we will create a button and then store the button text in a variable "mytext". Using the variable, we will display the text in a Label widget.#Import tkinter library from tkinter import * from tkinter import ttk #Create an instance of tkinter frame or window win= Tk() #Set ... Read More
2K+ Views
In software industries, whenever developers add a new feature, fix bugs in a particular application, they name the application to a new version, as it helps to recognize the recently updated features in that application.Using Python, we can get the version of any application. We will use pywin32 to interact with the executable files. It provides access to the win32 API which gives the ability to create COM and objects.First, install the required package by typing pip install pywin32 in the command shell.Import Dispatch to get the version number of the application.Create a variable to store the location of the ... Read More
4K+ Views
To extract hyperlinks from PDF in python can be done by using several libraries like PyPDF2, PDFminer and pdfx etc. PyPDF2 : A python bulit-in library acts as PDF toolkit, allows us to read and manipulate PDF files. PDFMiner : Tool used for extracting information from PDF documents, it focuses entirely on getting and analyzing text data. ... Read More
9K+ Views
The window manager implements the Tkinter window control icons. To hide and show the Tkinter window control icons, we can use the built-in function, which describes whether we want to disable control icons’ functionality.To disable the Exit or [X] control icon, we have to define the protocol() method. We can limit the control icon definition by specifying an empty function for disabling the state of the control icon.Example#Import the tkinter library from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame win= Tk() #Define the geometry of the function win.geometry("750x250") def close_win(): win.destroy() def disable_event(): ... Read More