
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
Found 10476 Articles for Python

2K+ Views
There are certain ways through which Tkinter widgets can be positioned inside a window. Tkinter Geometry manager has three methods, pack(), place() and grid(), through which we can set the position of the widget in an application window. Each of these ways has its own limitations and uses. To set the position of a button on a Tkinter application window, we can prefer to use the place(x-coordinates, y-coordinates) method over all the other methods. It takes the values of x and y coordinates which are required to define the position of a widget.ExampleThe sample code contains a button widget that ... Read More

20K+ Views
Tkinter Combobox is used to add a drop-down menu to the Entry widget, making it useful to handle multiple data of any application. A Combobox widget can be created using the Combobox(arguments). However, for the particular need of an application, we can set the default value for the Combobox widget. It can be set by listing all the records in a variable that needs to be present in the Combobox. By specifying the index of the particular value in the current(index) method, we can set the default value in the Combobox widget.Example#Import Tkinter library from tkinter import * from tkinter ... Read More

3K+ Views
Tkinter Listbox widgets are used to display scrollable boxes with vertically stacked menus. Within the window, the user can select either one or multiple items from the widget. In Tkinter, all the widgets are aligned either vertically or horizontally, and sometimes it seems difficult to arrange the widget position whenever we resize our window.We can configure the Listbox widget property by using expand=True and fill=BOTH property. These properties ensure that the widget stretches both vertically and horizontally. However, expand allows the widget to grow in available space.Example#Import tkinter library from tkinter import * #Create an instance of Tkinter frame or ... Read More

1K+ Views
Tkinter initially displays a window that contains all the widgets and components. When we look on the Tkinter Menubar, it displays some "leaf" default icon for every Tkinter application. In order to change the default icon of the Tkinter window, we can use iconbitmap("icon location") method. It takes the location of the icon file and displays the window with a particular icon.ExampleIn this python script, we have created an icon and used it for the output window.#Import tkinter library from tkinter import * #Create an instance of tkinter frame or window win= Tk() #Set the geometry of tkinter frame win.geometry("750x250") ... Read More

6K+ Views
Python is well known for its large set of libraries and extensions, each for different features, properties and use-cases. To handle PDF files, Python provides PyPDF2 toolkit which is capable of processing, extracting, merging multiple pages, encrypting PDF files, and many more. It is a very useful Package for managing and manipulating the file streams such as PDFs. Using PyPDF2, we will create a Tkinter application that reads the PDF file by asking users to select and open a PDF file from the local directory.To create the application, we will follow the steps given below −Install the requirement by typingpip ... Read More

3K+ Views
When a user wants to open a file from a directory, the preferred way to do this is to display a popup where the user selects a file to Open. Like most tools and widgets, Tkinter provides us a way to open a dialog for opening a file, reading a file, saving a file. All these functionalities are part of filedialog Module in Python. Just like other widgets, filedialog needs to be imported explicitly in the notebook. There are certain other modules that contain the filedialog such as, askdirectory, askopenfilename, askopenfile, askopenfilenames, asksaveasfilename, etc.ExampleIn this example, we will define a ... Read More

9K+ Views
Events are very useful to perform and manage multiple tasks in a large-scale application. We can bind a particular event with the keyboard buttons or mouse buttons using the bind(‘handler’, ‘callback’) method. Generally, the mouse pointer and its motion are tracked for the purpose of building a screensaver, 2D or 3D games. In order to print the coordinates of the pointer, we have to bind the Motion with a callback function that gets the position of the pointer in x and y variables.Example#Import tkinter library from tkinter import * #Create an instance of tkinter frame or window win= Tk() #Set ... Read More

8K+ Views
Word Wrapping plays a significant role in any textual information. It is an important feature for any text editor which breaks the section of a particular text to fit into multiple sections of lines where possible. It is used to fit the content in the width of a text document. In Tkinter, we can wrap the words or chars in the text widget using the wrap property. The default values for the wrap properties are – WORD, CHARS, or NONE.ExampleIn this example, we will wrap all the words of a text widget using the wrap property.#Import tkinter library from tkinter ... Read More

5K+ Views
Canvas is one of the flexible widgets in tkinter which controls the widgets with its power of functions, methods, and attributes. However, tkinter canvas can be used to create text using the create_text(options) constructor. We can define the text along with other properties in the constructor. After defining the text, we can control over the text style such as font-family, font-size and font-style by using font(property).ExampleLet us have a look at the following example where we will add a new text and then resize it using the font property.#Import tkinter library from tkinter import * from tkinter import ttk #Create ... Read More

2K+ Views
Tkinter Buttons can be configured through the different available attributes and properties in Tkinter. We can add a sticky property to make it sticky relative to the window in which it is residing. The sticky property allows the widget to set the relative position in the window. To make a button sticky, we have to choose the direction or position such as N, E, S, W, NE, NW, SE, SW, and zero.Example#Import the tkinter library from tkinter import * from tkinter import ttk #Create an instance of tkiner frame win= Tk() #Define the geometry of the function win.geometry("750x250") #Create a ... Read More