Tkinter and no root window

jerf at 192.255.255.255 jerf at 192.255.255.255
Wed Oct 2 20:58:35 EDT 2002


Please correct the following whenever appropriate. ;-)

I am writing an editor program in Tkinter. Tkinter has the root window
created with Tk(), which acts as the "master" window for the program. I
think, based on reading Tkinter.py, that this is because it has the tcl
interpreter instance associated with it.

My problem is I want to create one window per document I have open, which
I have working correctly with the Toplevel widget. However, closing the
original window closes the entire program. What is the best way to avoid
this behavior?

I would be happy if I could just tell the root window not to display; I'm
perfectly happy to maintain my own list of open windows and terminate the
program when they are all closed.

Looking at Tkinter.py, there was a promising functional called
"NoDefaultRoot", but that doesn't seem to suppress the root window from
coming up. (I guess it does something else?)

Right now, it looks to me like I'm going to have to create a fake-o Tk-type
class that has an associated tcl interpreter but does not display a window
itself, and pass that around as the "master widget" class of all of the
Toplevel windows I display. Before I embark upon that potentially
dangerous route (both because of potential difficulty and potential bugs I
may introduce), does anyone have a better suggestion? Or things I need to
watch out for?

I tried searching for an answer on Google but this is one of those
questions that gets swamped by irrelevent answers because the best search
terms you know are things like "Tkinter root window"; not enough for the
search engine to go on.



More information about the Python-list mailing list