[Tkinter-discuss] How to dettach a Toplevel

Michael Lange klappnase at web.de
Thu Nov 30 11:17:03 CET 2006

Hi Sorin,

> While the two toplevel solution will work nicely, I'm not sure how would I close the main application (at one point I want to be able to do so).

As a second thought, you actually do not need two Toplevel windows, you simply
could withdraw the main gui window instead of closing it when the user hits the
"close" button (use: root.protocol("WM_DELETE_WINDOW", root.withdraw)).
This way the popup Toplevel window is still alive after the user has "closed" the app
and can do what it is supposed to. If you want to restore the main gui later,
there might be a menu or something in the popup window or maybe a lock file
to make sure the app will be started only once.

> As for the other suggestion, that was my first approach, but it doesn't work. I don't know why,
> and sometime I'll have to find out, as I'll need later in my project.
> What happens is that when the users logs in (no authentication required) I have a small script in 
> KDE Autostart to issue an
> xhost local:root
> allowing the daemon to show his stuff.
> The daemon waits until KDE is up and running and xhost was executed, then it does a
> root=Tk(screenName=':0.0')
> Nothing comes on. If I fire up a Python interpreter and do the things manualy, it works
> flawless: I have a graphic window controlled by root, can populate it, withdraw it, iconify it,
> destroy it... It proves that from an X server standpoint things are set correctly, but my daemon does something wrong (it may be that the window is created and destroyed immediately, I don't know).

Hm, sorry, besides what John suggested, no further ideas here.


More information about the Tkinter-discuss mailing list