Exit app code

Fantastic! Thank you (and Tacão and Bruce) for your responses!

Tim

···

-----Original Message-----
From: Jeff Shannon [mailto:jeff@ccvcorp.com]
Sent: Monday, October 20, 2003 3:16 PM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] Exit app code

Tim Royal wrote:

Hi, I have an app that, on exit, will save settings about the app (x,y
on screen, height, width, some customized view information).

Right now, it works great if I close from the file menu, and do an
wxGetApp().ExitMainLoop().

My question is, how do I trap exiting in other ways (right click the X
on the right corner of the window, etc.). When I do this, the
ExitMainLoop() is never run and I get error messages.

What you want to do is to catch your frame's EVT_CLOSE. Your handler
for it should save your settings & configuration, and then call
frame.Destroy() to finish the process. This should work for every
variety of (normal) application exit, because part of exiting the app
will always be that your frame closes. (Note that this also means
that you can exit gracefully by sending wxEVT_CLOSE to your frame.) I
typically have an OnCloseWindow() method that is used as the handler
for both EVT_CLOSE and the File->Exit menu item.

Jeff Shannon
Technician/Programmer
Credit International

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

_________________________________________________
Scanned on 20 Oct 2003 23:13:08
Scanning by http://erado.com