Tkinter generally provides three general ways to define the geometry of the widgets. They are − Place, Pack, and Grid Management. If we use the Pack geometry manager, then place the two buttons in the frame using side property. It places the buttons horizontally stacked in the window in (Left, Right, Top and Bottom) direction. The side property maintains the same width and internal padding between all the adjacent widget in the application.Example#Import the required Libraries from tkinter import * from tkinter import ttk import random #Create an instance of Tkinter frame win = Tk() #Set the geometry of Tkinter frame ... Read More
Tkinter Entry widget is used to insert single-line text input. We can use the Entry widget to create forms where single-line input is the prime requirement.Sometimes, we need to insert a predefined text inside the Entry Widget. In such cases, we can use insert(INSERT, ) method. These are generally called as Placeholders for the Entry widget.Let us suppose that we want to change the state of our text as read-only. Here, we can use state= ‘readonly’ property while configuring the Entry widget.Example#Import the required Libraries from tkinter import * from tkinter import ttk #Create an instance of tkinter frame win = ... Read More
Tkinter Listbox widgets are used to display a scrollable list of items with vertically stacked menus. Sometimes, we may need to set the list item selected, by default. We can use the select_set(list_item_index) method by specifying the index of the list items that need to be selected by default.So, let us suppose that we have a list of programming languages in our Listbox and what we want is to set the first item selected, then we can provide the index of a first list item in the method. The method must be invoked before the end of mainloop() function.Example#Import tkinter ... Read More
A Button can be initialized using the for loop in a Tkinter application. Let us suppose that we want to create multiple buttons, each with different commands or operations defined in it. We have to first initialize the Button inside a for loop. The iterator will return the object for which multiple instances of the button will be created.ExampleIn this example, we will define some buttons that will have different commands or functionalities.#Import the required Libraries from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame win = Tk() #Set the geometry of the Tkinter frame win.geometry("750x250") ... Read More
Let us suppose that we want to create a standalone app (executable application) using tkinter. We can convert any tkinter application to an exe compatible file format using the PyInstaller package in Python.To work with pyinstaller, first install the package in the environment by using the following command, pip install pyinstallerOnce installed, we can follow the steps to convert a Python Script File (contains a Tkinter application file) to an Executable file.Install pyinstaller using pip install pyinstaller in Windows operating system. Now, type pyinstaller --onefile -w filename and press Enter.Now, check the location of the file (script file) and you will ... Read More
Let us suppose that we are creating an application in which we want to change the color of the Button widget while we hover upon it. We can have the hovering property by defining the Event Callbacks.To change the color of the Button while hovering on it, we have to bind the and events. For each event, we will configure the button property such as background color, foreground color, etc.Example#Import required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Define the geometry of the window win.geometry("750x250") #Define functions def on_enter(e): button.config(background='OrangeRed3', foreground= ... Read More
Let us suppose that for a particular application, we want to bind the mouse double-click so that it performs some event or operation. We can use the bind(‘’, handler) or bind(‘’, handler) methods to bind the mouse Left or Right Buttons with a handler or a callback function.ExampleIn this example, we will create an application that contains a button. When we double click the button, it will open a popup window.#Import required libraries from tkinter import * from tkinter import ttk #Create an instance of tkinter frame win= Tk() #Define the geometry of the window win.geometry("750x250") #Define a function def ... Read More
In order to close a Tkinter application, we generally refer to close the parent window using the destroy() method. To close the Tkinter window automatically after a certain time limit, we have to use the after(time in ms, callback) method by specifying the time and the callback function which needs to be run after a certain time limit.Example#Import the required Libraries from tkinter import * from tkinter import ttk #Create an instance of tkinter frame win = Tk() #Set the geometry of tkinter frame win.geometry("750x270") #Initialize a Label widget Label(win, text= "This window will get closed after ... Read More
Even if you have a public repository in GitHub, not everyone has the permission to push code into your repository. Other users have a read-only access and cannot modify the repository. In order to allow other individuals to make changes to your repository, you need to invite them to collaborate to the project.The following steps should be performed to invite other team members to collaborate with your repository.Step 1 − Click on the Settings tab in the right corner of the GitHub page.Step 2 − Go to Manage Access option under the Settings tab. On the Manage Access page, you ... Read More
A GitHub account is a pre-requisite for creating a GitHub repository. Follow the below steps after registering with GitHub.Step 1 − Login to the GitHub account. Once you login to your account you will see a ‘+’ button on the right. Click on the button and select "New repository" option to create a new repository.Configure the following in the create a new repository page.Repository name: GitHub will validate the repository name that you have entered.Type of the repository: GitHub lets you create the following types of repositories −Private repository − Private Repository is the one that can be accessed only ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP