[wxpython-users] Catching Shutdown Events
raffaello
barbarossa.platz at gmail.com
Tue May 27 01:34:57 PDT 2008
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 at 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 =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()
>
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200805=
27/9f76f2cf/attachment.htm
More information about the wxpython-users
mailing list