- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 605 Articles for Tkinter
6K+ Views
Sometimes, we want to remove a widget that is of no use in the application. We can delete widgets from the window or frame using the .destroy method in tkinter. It can be invoked in the widget by defining a function for it.ExampleIn this example, we have created a button that will remove the text label widget from the window.#Import the tkinter library from tkinter import * #Create an instance of tkinter frame win = Tk() #Set the geometry win.geometry("650x450") #Define a function to remove the text from the screen def delete_text(): text.destroy() #Create a ... Read More
11K+ Views
Tkinter displays the application window by its default size. However, we can display a full-screen window by using attributes('fullscreen', True) method. The method is generally used for assigning a tkinter window with properties like transparentcolor, alpha, disabled, fullscreen, toolwindow, and topmost.Example#Import the tkinter library from tkinter import * #Create an instance of tkinter frame win = Tk() #Set the geometry win.geometry("650x250") #Add a text label and add the font property to it label= Label(win, text= "Hello World!", font=('Times New Roman bold', 20)) label.pack(padx=10, pady=10) #Create a fullscreen window win.attributes('-fullscreen', True) win.mainloop()OutputRunning the above code will ... Read More
8K+ Views
In tkinter, we can create text widgets using Text attributes using packages. However, while creating a GUI application, sometimes we need to capture the input from a text widget.We can get the input from the user in a text widget using the .get() method. We need to specify the input range which will be initially from 1.0 to END that shows the characters starting and ending till the END.Example#Import tkinter library from tkinter import * #Create an instance of tkinter window or frame win=Tk() win.geometry("700x300") def get_input(): value=my_text_box.get("1.0", "end-1c") print(value) #Creating a text box widget ... Read More
16K+ Views
Tkinter initially creates a window or frame object where all the widgets, frame are displayed.Tkinter components adjust the window size and width according to user-defined geometry.In order to get the screen size, we can use winfo_screenwidth() which returns the screen width and winfo_screenheight() for the height of the screen in pixels.ExampleIn this example, we will print the screen size as the output, #Import the required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the geometry of frame win.geometry("650x250") #Get the current screen width and height screen_width = win.winfo_screenwidth() screen_height = win.winfo_screenheight() ... Read More
1K+ Views
Tkinter Labels are used to create and display text or images on the window. It has several components and functions that can be used to customize the label information such as fontfamily, padding, width, height, etc. In order to get the Label text on the window, we can write the value for the text that has to be displayed on the window.Example#Import the required library from tkinter import * #Create an instance of tkinter frame win= Tk() #Define the geometry of the window win.geometry("600x250") #Create a Label with Text my_text= Label(win, text= "This is a New Line ... Read More
13K+ Views
Tkinter is one of the widely used libraries for creating GUI-based applications. In order to create applications using Tkinter, we have to install and import the library in the notebook.First, we have to install the tkinter library in our local environment based on the Windows or Linux operating system.For Windows users −pip install tkinterorpip install tkFor Linux or Mac users −apt-get install python-tkOnce installed, the user can import the tkinter library in the notebook using the following command, from tkinter import* To check if tkinter is installed in the system or not, we can use the following command, import tkinter ... Read More
4K+ Views
To make a tkinter widget invisible, we can use the pack_forget() method. It is generally used to unmap the widgets from the window.ExampleIn the following example, we will create a label text and a button that can be used to trigger the invisible event on the label text widget.#Import the required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the geometry of frame win.geometry("600x250") #Set the resizable property False win.resizable(False, False) #Make the widgets Invisible def make_invisible(widget): widget.pack_forget() #Create a label for the window or frame label=Label(win, text="Hello ... Read More
2K+ Views
In order to make the tkinter window or the root window jump above all the other windows, we can use attributes method that will generally take two values specifying the “topmost” value and the other is a Boolean value.Example#Importing the library from tkinter import * #Create an instance of tkinter window or frame win= Tk() #Setting the geometry of window win.geometry("600x250") #Create a Label Label(win, text= "Hello Everyone!", font=('Helvetica bold', 15)).pack(pady=20) #Make the window jump above all win.attributes('-topmost', 1) win.mainloop()OutputRunning the above code will make the window stay above all other windows,Read More
7K+ Views
Tkinter initially creates a resizable window for every application. Let us suppose that we want to make a non-resizable window in an application. In this case, we can use resizable(height, width) and pass the value of height=None and width=None. The method also works by passing Boolean values as resizable(False, False).Example#Import the required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the geometry of frame win.geometry("600x250") #Set the resizable property False win.resizable(False, False) #Create a label for the window or frame Label(win, text="Hello World!", font=('Helvetica bold', 20), anchor="center").pack(pady=20) win.mainloop()OutputRunning the above code will ... Read More
8K+ Views
Whenever we create a GUI program, tkinter generally presents the output screen in the background. In other words, tkinter displays the program window behind other programs. In order to put the tkinter window on top of others, we are required to use attributes('- topmost', True) property. It pulls up the window on the upside.Example#Importing the library from tkinter import * #Create an instance of tkinter window or frame win= Tk() #Setting the geometry of window win.geometry("600x350") #Create a Label Label(win, text= "Hello World! ", font=('Helvetica bold', 15)).pack(pady=20) #Make the window jump above all win.attributes('-topmost', True) ... Read More
To Continue Learning Please Login
Login with Google