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

#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():

#Create another Toplevel Window
new_win= Toplevel(win)
new_win.title("NEW WINDOW")

#Hide the Main Window

#Create a Button to Hide/ Reveal the Main Window
button= ttk.Button(new_win, text="Show" ,command= show_win)



Running the above code will show the output as,

When we click the button "Show", it will display the Main window.

Updated on 03-May-2021 11:26:04