[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Cleaning Up an Application When the Window is Closed

wolf_tracks

2/18/2008 2:31:00 AM

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: <speckledwithStars.net>
2 Answers

Mike Driscoll

2/18/2008 3:08:00 AM

0

On Feb 17, 8:31 pm, "W. Watson" <wolf_tra...@invalid.com> 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: <speckledwithStars.net>

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-bi...

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

HTH

Mike

wolf_tracks

2/18/2008 3:35:00 AM

0

Good. Thanks.

Mike Driscoll wrote:
> On Feb 17, 8:31 pm, "W. Watson" <wolf_tra...@invalid.com> 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: <speckledwithStars.net>
>
> 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-bi...
>
> It actually mentions your problem specifically. I've never done it as
> I usually use wxPython.
>
> HTH
>
> Mike

--
Wayne Watson (Nevada City, CA)

Web Page: <speckledwithStars.net>