Cleaning Up an Application When the Window is Closed

W

W. Watson

Suppose I write some Win XP application using the Tkinter GUI, and do not
provide a mechanism to exit other than the user clicking on the X in the
upper right corner of a window. Is there a mechanism that will allow me to
put up an save-dialog to give the user the option to save his present state
of data?
 
M

Mike Driscoll

Suppose I write some Win XP application using the Tkinter GUI, and do not
provide a mechanism to exit other than the user clicking on the X in the
upper right corner of a window. Is there a mechanism that will allow me to
put up an save-dialog to give the user the option to save his present state
of data?

You just need to catch the close event, which appears to be
"WM_DELETE_WINDOW" in Tkinter. The following article details its usage
near the bottom of the page under the heading "Protocols":

http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm

It actually mentions your problem specifically. I've never done it as
I usually use wxPython.

HTH

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top