[wxpython-users] Re: Catching Shutdown Events

Jesse Aldridge jessealdridge at gmail.com
Tue May 27 12:11:43 PDT 2008


No luck, it behaves the same as before: If I close the frame, it works.  If
I shutdown, it doesn't work.

import os

import wx

print wx.version()

class MyApp(wx.App):
    def __init__(self):
        wx.App.__init__(self)
        self.Bind(wx.EVT_END_SESSION, self.on_end_session)

    def on_end_session(self, e):
        out =3D open(os.path.expanduser("~/Desktop/end_session_app.txt"), "=
w")
        out.write("ended session from App")
        out.close()
        e.Skip()

class MyFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None)
        self.Bind(wx.EVT_CLOSE, self.on_close)

    def on_close(self, e):
        out =3D open(os.path.expanduser("~/Desktop/closed_frame.txt"), "w")
        out.write("closed the Frame")
        out.close()
        e.Skip()

app =3D MyApp()
frame =3D MyFrame()
frame.Show(True)
app.MainLoop()




On Tue, May 27, 2008 at 2:00 PM, raffaello <barbarossa.platz at gmail.com>
wrote:

> Try putting the event handler of wx.EVT_CLOSE inside the frame, and not t=
he
> app.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200805=
27/f6e8a1bd/attachment.htm


More information about the wxpython-users mailing list