Hi all,

How would you add some code that is called when the application is
terminated, that is independent of whether it was closed via the
window manager or via some programmatic call within the application,
such as a call from a "quit" button?

I tried binding to the "destroy" event like this:

from Tkinter import *

def destroyed(*args):
    print "AAARRGGGH!!!"

root = Tk()

button = Button(root, text="QUIT", command=root.quit)
button.grid()

# This line seems to lead to Python crashes on Windows
root.bind("<Destroy>", destroyed, "+")
root.mainloop()

but this produces Python crashes on Windows, and doesn't work on Linux
either if the Quit button is pressed. Changing to
"command=root.destroy" works
on Linux but produces a hang on Windows.

There must be a better way, surely?

Regards,
Geoff
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to