[Tutor] about tkinter

Alan Gauld alan.gauld at freenet.co.uk
Tue Sep 5 19:09:45 CEST 2006


>> Here is a very short example of creating two windows:
>>
>> >>> from Tkinter import *
>> >>> win = Tk()
>> >>> win1 = Toplevel(win)
>> >>> f = Frame(win)
>> >>> f.pack()
>> >>> g = Frame(win1)
>> >>> g.pack()
>> >>> Label(f,text="Main").pack()
>> >>> Label(g,text="Sub").pack()
>> >>> win.mainloop()

> If I close the 'main' window, 'sub' window will be closed too. How 
> can
> I close just one window?

You need to hide the main window (there must be one(*) but it can be
very small!) and then make all your visible windows Toplevels.

(*)That may not be true but I don't know of a way to avoid it...

Alan g. 



More information about the Tutor mailing list