I have a problem connected with line 9 in the below timer. The timer counts EndTime down to zero and then repeats a sound file five times. When the repeats start the CountDown label is reconfigured, but the display isn't updated until after the sound file ends. This means that the label is four seconds (the length of the sound file) out of step. How can I force the display to update now?
Code:
# one second decrement
def decrement():
global EndTime, Repeat
if StopIt.get() == True or Repeat > 5:
Alarming.set(False)
StopAlarm.configure(state='normal')
return 0
EndTime -= 1
if EndTime < 0:
CountDown.configure(text='Repeat ' + str(Repeat), bg='red', fg='yellow')
EndTime = 5
Repeat += 1
if SaysOn.get() == True:
playsound('/media/Avocet/Python/says.wav')
else:
playsound('/media/Avocet/Python/hoot.wav')
elif Repeat == 0:
CountDown.configure(text=(str(int(EndTime / 3600)) + 'h ' + str(int((EndTime % 3600) / 60)) + 'm ' + str(EndTime % 60) + 's'))
Window.after(1000, decrement)
Other than this the timer works as intended. In case it makes a difference, I'm using tkinter.
Mike