wxTimer never times out sometimes
Jeffrey Barish
jeff_barish at earthlink.net
Wed Aug 23 14:59:35 PDT 2006
Robin Dunn wrote:
> Jeffrey Barish wrote:
>> Jeffrey Barish wrote:
>>
>>>> Have you tried .Stop() then .Start()?
>>>>
>>>> - Josiah
>>> I did not try it because the documentation says that "If the timer was
>>> already running, it will be stopped by this method [start] before
>>> restarting it." However, if you think that it might make a difference,
>>> I
>>> will try it. At this point, I have nothing else to try, so any
>>> suggestion is welcome.
>>
>> It's official: This sensible suggestion did not fix the problem.
>>
>> As this is the only serious problem I have remaining in my application
>> and as I am stumped, I thought that a peek at some of the code might
>> trigger additional thoughts.
>>
>> The function that I use to trigger the timer is this:
>>
>> def _startTimer(self):
>> '''Utility function for starting the timer and activating the
>> indicator.'''
>> self.timer.Start(10000, True)
>> self.ind_p.setInd()
>>
>> The timeout event is bound to this:
>>
>> def doTimer(self, event):
>> '''The timer timed out.'''
>> print 'Timeout'
>> self.ind_p.clrInd()
>>
>> The _startTimer utility routine is the only place where the timer Start
>> is
>> called. What I observe is that the indicator goes on but it never goes
>> off
>> and I never get a message from the print statement. The fact that the
>> indicator went on tells me that the timer must have started, yet I never
>> make it to the event handler. The binding never changes. It is created
>> with this:
>>
>> self.Bind(wx.EVT_TIMER, self.doTimer, self.timer)
>>
>> where self is the main panel.
>>
>> Also, once the timer fails once, I can't find any way to trigger it
>> again. I keep thinking that it will trigger if I do the things that
>> normally trigger it and when it times out it will belatedly clear the
>> indicator and
>> print the message. However, nothing I do has this effect.
>>
>> I just stuck
>>
>> if self.timer.IsRunning():
>> print 'Started timer'
>> else:
>> print 'Failed to start timer'
>>
>> at the end of _startTimer. It will be interesting to see whether the
>> timer thinks that it is running when the indicator fails to clear.
>>
>> I don't have event.Skip() at the end of doTimer. Could that be the
>> problem?
>
> It shouldn't cause any problems. The default handler doesn't do anything.
>
> You didn't show the code that creates the timer object.
>
self.timer = wx.Timer(self, wx.ID_ANY)
where self is the main panel.
--
Jeffrey Barish
More information about the wxpython-users
mailing list