IcyFlame
IcyFlame

Reputation: 5199

How to show a window that was hidden using "withdraw" method?

I would like to show a window after I called withdraw.

The following is my current code:

from Tkinter import *

def callback():    
    global root
    root.withdraw()
    win2 = Tk()

root = Tk()
Label(root,text='this is a window').pack()
Button(root,text='withdraw',command=self.callback).pack()
mainloop()

As soon as I press the button, the window disappears much as I want it, and another window appears and everything works great. How do I get the first window back, in the same state as it was before?

Upvotes: 11

Views: 28746

Answers (1)

IcyFlame
IcyFlame

Reputation: 5199

Use the following commands when you want to show the window:

# root.update()  # not required
root.deiconify()

If you want to know more about it, see here.

Upvotes: 14

Related Questions