Tk's default Toplevel - counterintuitive
chad at vision.arc.nasa.gov
Thu Aug 19 20:10:16 EDT 1999
Gary Herron wrote:
> Stuart Reynolds wrote:
> > Does anyone know how to tell if Tk has already instaniated a Toplevel
> > window? I want to be able to open several Toplevel windows in any order.
> Perhaps the easiest way is to never use the default top level window:
> from Tkinter import *
> DefaultTop = Tk()
> DefaultTop.withdraw() # Never to be seen
Just be careful if you do this, to remember that if you are relying on the
behavior of closing all the visible windows to end your program, it won't.
The withdrawn() window is still running mainloop(), and needs to be
interrupted somehow. There are some ways around this using callbacks,
etc. So, depending on the behavior you prefer, this method or my method
each have their strengths.
PS. What is the way to register a callback so that you can intercept the
window manager's request to destroy a window? Then you could just bind
the sys.exit call to this on the Tk object...
More information about the Python-list