Maybe on_end_session should be written in a subclassing of wx.App().
But, since an application ends when the last one of its frames has closed, you could bind wx.EVT_CLOSE to an event handler in the top frame, and put there your shutdown code. And this solution surely works.
···
2008/5/27 Jesse Aldridge jessealdridge@gmail.com:
So my app needs to save changes on shutdown or logoff, but the events don’t seem to get caught. Here’s some test code. What am I doing wrong?
import os
import wx
app = wx.App()
frame = wx.Frame(None)def on_end_session(e):
out = open(os.path.expanduser(“~/Desktop/end_session.txt”), “w”)
out.write(“ended session”)
out.close()
e.Skip()frame.Bind(wx.EVT_END_SESSION, on_end_session)
app.Bind(wx.EVT_END_SESSION, on_end_session)frame.Show(True)
app.MainLoop()
wxpython-users mailing list