- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to control automated window resizing in Tkinter?
The Tkinter window can be resized manually by defining the geometry ("width × height") method. We can automate or reset the window to its original form by passing an empty value to the geometry manager. Once the empty value is passed to the method, it will get resized automatically. In this example, we will create a Tkinter application that will display a Toplevel window (Popup window) with a defined size. When we press a RESET button, it will be resized again to its default size.
#Import the library from tkinter import * from tkinter import ttk #Create an instance of tkinter frame win= Tk() #Set the window geometry win.geometry("750x200") #Create a Label Label(win, text= "Tkinter is a GUI Library in Python", font=('Helvetica 15 bold')).pack(pady=20) #Define a function to reset the window size def reset_win(): win.wm_geometry("750x250") button.destroy() #Create a Button to Hide/ Reveal the Main Window button= ttk.Button(win, text="RESET" ,command= reset_win) button.pack(pady=50) win.mainloop()
Running the above code will display a window that contains a button. Once we click the RESET Button it will get resized to its default size which prevents the window to be resized manually.
Now, click the Button to reset the size of the Main window that will automatically get resized to its default size.
- Window Resizer Control Panel in Tkinter
- Dynamically Resize Buttons When Resizing a Window using Tkinter
- How to stop Tkinter Message widget from resizing?
- Resizing pictures in PIL in Tkinter
- Resizing images with ImageTk.PhotoImage with Tkinter
- How to show webcam in TkInter Window?
- How to draw images in the Tkinter window?
- How can I control Chromedriver open window size?
- How to keep the window focus on the new Toplevel() window in Tkinter?
- Tkinter-How to get the current date to display in a tkinter window?
- How to make a Tkinter window not resizable?
- How to delete Tkinter widgets from a window?
- How to make Tkinter Window appear in the taskbar?
- Function to close the window in Tkinter
- How to put a Toplevel window in front of the main window in Tkinter?