After you've created the timer, you can bind the wx.EVT_TIMER event within your event handling widget with a line of code as in the following.
If you need to bind handlers for more than one timer to more than one handler function, you can either pass each timer's ID to Bind, or pass the timer object as the source parameter.
timer1 = wx.Timer(self) timer2 = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.OnTimer1Event, timer1) self.Bind(wx.EVT_TIMER, self.OnTimer2Event, timer2)
Just like all the other event code we've seen, this causes wxPython to react to the wx.EVT_TIMER event by passing control to the OnTimerEvent() method (or whatever method you put in that place).
Was this article helpful?