[wxpython-users] Catching Shutdown Events

Jesse Aldridge jessealdridge at gmail.com
Mon May 26 23:13:24 PDT 2008


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 =3D wx.App()
frame =3D wx.Frame(None)

def on_end_session(e):
    out =3D 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()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200805=
27/b6c4884f/attachment.htm


More information about the wxpython-users mailing list