[wxPython] "Catching" a shutdown event

...
> And add a
> self parameter to OnExit.

This is just where I'm getting stuck.

Tried the following, got traceback:
File "LabTracker_Dev.py", line 1730, in LTApp
    EVT_END_SESSION(self, OnExit)
NameError: name 'self' is not defined

class LTApp(wxApp):
    def OnInit(self):
        frame = ChoiceFrame(NULL, -1, "Welcome! - Log In or Sign up")
        frame.Show(true)
        self.SetTopWindow(frame)

        return true

    def OnExit(self):
        print "I just Exited."

    EVT_END_SESSION(self, OnExit)

app = LTApp(0)
app.MainLoop()

Tried the offending line this way and got the same error:
    EVT_END_SESSION(self, self.OnExit)

Tried the offending line this way:
    EVT_END_SESSION(OnExit)

Got this error, which seems consistent with the rest of
wxPython, but given
the foregoing I don't know how to deal with it.
  File "LabTracker_Dev.py", line 1730, in LTApp
    EVT_END_SESSION(OnExit)
TypeError: EVT_END_SESSION() takes exactly 2 arguments (1 given)

Shouldn't you be calling EVT_END_SESSION within a function (probably the
class __init__ function) rather than at class level? I'm not even sure what
calling a function at class level would do...

Paul.

···

From: John Hopkins [mailto:john@hopkinsit.com]