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?
If that's wrong, I would expect to see a problem all the time, not 1 time
out of 100. Still, maybe some memory is not getting freed, or something
like that. I'll stick it in and see what happens.
···
--
Jeffrey Barish