Cleaning Up an Application When the Window is Closed

Mike Driscoll kyosohma at
Mon Feb 18 04:08:06 CET 2008

On Feb 17, 8:31 pm, "W. Watson" <wolf_tra... at> wrote:
> 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?
> --
>                           Wayne Watson (Nevada City, CA)
>                         Web Page: <>

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":

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



More information about the Python-list mailing list