On Tue, 5 Sep 2006 01:46:02 -0700
"linda.s" <[EMAIL PROTECTED]> wrote:

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

Hi Linda,

you can use a "hidden" root window, like this:

    root = Tk()
    root.withdraw()# hide the root window
    top1 = Toplevel(root)
    top2 = Toplevel(root)

Don't forget to define a method that exits the application when the last 
Toplevel
is being closed, because if you close both Toplevels the root window is still 
there and no
way to close it from the gui.
Here is a primitive to show how this might work:

    def close_top1():
        global top1
        top1.destroy()
        top1 = None
        if top2 is None:
            root.quit()

    top1.protocol("WM_DELETE_WINDOW", close_top1)

( and the same for top2 of course)

This makes the close_top1() function be executed when the "X" in the window's 
upper right
corner is clicked.

I hope this helps.

Michael
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to