How to do cleanup when system shutdown closes the app?

The EVT_CLOSE event doesn't get sent when an application terminates when
the system shuts down (so for example the SDI demo app doesn't ask for
files to be saved when you shut the system down, only when you close the
app explicitly); is there some way to get cleanup code executed on
system shutdown as well as when the user closes the application?

Thanks.

I'm not sure if I've ever tried this, but you're looking for the EVT_QUERY_END_SESSION and EVT_END_SESSION events, which are sent to the wx.App object. It's done in two passes, on the first pass all apps get the EVT_QUERY_END_SESSION event giving them a chance to either save files or Veto the shutdown. Then when all apps have acknowledged without a veto then the EVT_END_SESSION is sent to let you know that the system is in fact logging out or shutting down.

ยทยทยท

Avery.Andrews@anu.edu.au wrote:

The EVT_CLOSE event doesn't get sent when an application terminates when
the system shuts down (so for example the SDI demo app doesn't ask for
files to be saved when you shut the system down, only when you close the
app explicitly); is there some way to get cleanup code executed on
system shutdown as well as when the user closes the application?

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!