Don't understand wxPython event handling

Robin Dunn robin at alldunn.NOSPAM.com
Thu Apr 1 17:46:33 EST 2004


Robert wrote:
> I also have anouther question:
> 
> which is the better way to register to events:
> eventManager.Register(self.OnPageDone,EVT_PAGE_DONE,self.pageContainer)
> 
> or
> 
> EVT_PAGE_DONE(self, self.OnPageDone)
> 
> 

Short answer: It depends.

Long answer:  The eventManager sits on top of a Publish/Subscribe 
framework (Observer design pattern) so it is useful if you want to have 
lots of handlers for a specific event and/or if you want your handlers 
to be loosly coupled with the windows where the event was generated.  If 
you put your handlers in the same class as the window that generated the 
event (or a parent window) then using the simpler form is just fine.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!




More information about the Python-list mailing list