wxpython Timer Event Interval

wxpython

Solution

I wrote a tutorial on timers a while back that might help you figure this out. Basically you do as you mentioned in the first code snippet. You have to Start the timer and pass it a value in milliseconds. So 1000 would = 1 second. You don't need that bit with the wx.TimerEvent. At least, I've never needed that.

Anyway, the timer event fires every 750 milliseconds in your example, or a little less than a second. I think if you machine's CPU gets pegged, it can interrupt or delay timer events, but otherwise they're very reliable.

Problem

I am trying to write a gui application with wx python and I need to control the interval of the timer event. Here is my code currently: ``` self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_timer, self.timer) self.timer.Start(750) # start timer after a delay ``` This is the right framework but I cannot control the interval or how often the EVT_TIMER occurs. I have been trying to figure out using the wx TimerEvent class but without any luck. I feel like this should be what I need but it isn't working: ``` self.timer = wx.Timer(self) self.timerEvent = wx.TimerEvent(self.timer.GetId(),10) self.Bind(wx.EVT_TIMER, self.on_timer, self.timer) ``` Thanks!

Original source