[Tkinter-discuss] How to catch when the root window closes?
Snakey
darr_low at yahoo.com
Fri Apr 11 04:29:14 CEST 2008
would think that the root window is exited by using the "X" windows close
button? If this is the case, you can bind the window manager event
WM_DELETE_WINDOW to a handler. Try this:
root = Tk()
...
... some other codes
# --------------------------
# to bind the window manager's CLOSE event to a fn
# --------------------------
root.protocol( "WM_DELETE_WINDOW", my_function )
# so when the user press the "x" button, my_function is executed. Write
watever code you need in my_function(), and at the end of
# the function, you can execute root.destroy to close the application.
inhahe wrote:
>
> I tried doing root.bind("<Destroy>",onquit)
> but i don't get why onquit is called *18* times when I exit the app.
> what's the ideal way to execute something *once* when the app is exited?
> Thanks,
> inhahe
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>
>
--
View this message in context: http://www.nabble.com/How-to-catch-when-the-root-window-closes--tp16290559p16623951.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
More information about the Tkinter-discuss
mailing list