Don't understand wxPython event handling

Robert rmanx at gmx.de
Thu Apr 1 07:00:19 EST 2004


Hello list,

could somebody point me to a good reference about wxPython event handling?
I have seen many examples but which one is the best. Waht are the advantages
and disadvantages?

Can you also have a short look at the example below and give me some
comments, please?

Example:
I have implemented (or copied from somewhere) one event in two flavours.
Both work, but which one is the best? Or does anybody have a better
implementation.

EVT_NEXT_PAGE_ID = wxNewId()

def EVT_NEXT_PAGE( win, func ):
    """Your documentation here"""
    win.Connect( -1, -1, EVT_NEXT_PAGE_ID, func )

class showNextPageEvent(wxPyEvent):
    def __init__(self, windowID):
        wxPyEvent.__init__(self)
        self.SetEventType(EVT_NEXT_PAGE_ID)


or

EVT_NEXT_PAGE_TYPE = wxNewEventType()

def EVT_NEXT_PAGE( window, function ):
    """Your documentation here"""
    window.Connect( -1, -1, EVT_NEXT_PAGE_TYPE, function )

class showNextPageEvent(wxPyCommandEvent):
    eventType = EVT_NEXT_PAGE_TYPE
    def __init__(self, windowID):
        wxPyCommandEvent.__init__(self, self.eventType, windowID)
    def Clone( self ):
        self.__class__( self.GetId() )


Thank you

Robert





More information about the Python-list mailing list