- 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 show a window that was hidden using the "withdraw" method in Tkinter?
Tkinter withdraw method hides the window without destroying it internally. It is similar to the iconify method that turns a window into a small icon. Let us suppose we want to reveal the hidden window during the execution of an application then we can use deiconify() method. It can be invoked with the window or frame of a widget in the application.
In this example, we will define a button in a Toplevel window (Popup Window) which can be the trigger to reveal the main window.
#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 show the Main window def show_win(): win.deiconify() #Create another Toplevel Window new_win= Toplevel(win) new_win.geometry("700x250") new_win.title("NEW WINDOW") #Hide the Main Window win.withdraw() #Create a Button to Hide/ Reveal the Main Window button= ttk.Button(new_win, text="Show" ,command= show_win) button.pack(pady=50) win.mainloop()
Running the above code will show the output as,
When we click the button "Show", it will display the Main window.
- How to show webcam in TkInter Window?
- How to remove the title bar in a Tkinter window without using overrideredirect() method?
- How to take a screenshot of the window using Python?(Tkinter)
- How to get the name of a test method that was run in a TestNG teardown method?
- How to animate and show a hidden div in jQuery?
- Tkinter-How to get the current date to display in a tkinter window?
- How do I create a popup window using Tkinter?
- How to put a Toplevel window in front of the main window in Tkinter?
- How to draw images in the Tkinter window?
- How to center a window on the screen in Tkinter?
- How to make a Tkinter window jump to the front?
- How to bind the Enter key to a tkinter window?
- How to keep the window focus on the new Toplevel() window in Tkinter?
- How to copy from clipboard using tkinter without displaying a window
- How to add a margin to a tkinter window?