
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
Show Hidden Window Using 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.
Example
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()
Output
Running the above code will show the output as,
When we click the button "Show", it will display the Main window.
Advertisements