There are two main types of Event Objects in wxPython, each with its own distinct behavior:
Events
Command Events
Basic Event
s are events that do not propagate upwards in the window hierarchy. Instead, they stay local to the window that they were sent to or originated in. The second type, CommandEvents
, are the more common type of events, and differ from regular events in that they propagate up the window parental hierarchy until they are handled or reach the end of the line at the application object. This recipe will explore how to work with, understand, and control the propagation of events.
To explore how events propagate, lets create another simple application:
import wx ID_BUTTON1 = wx.NewId() ID_BUTTON2 = wx.NewId() class MyApp(wx.App): def OnInit(self): self.frame = MyFrame(None, title="Event Propagation") self.SetTopWindow(self.frame) self.frame.Show() self.Bind(wx.EVT_BUTTON, self.OnButtonApp) ...