Article 56PT0 Python - force display update?

Python - force display update?

by
Mik3e
from LinuxQuestions.org on (#56PT0)
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.

Mikelatest?d=yIl2AUoC8zA latest?i=u7R9avz9X1U:t3ghQSAoNy8:F7zBnMy latest?i=u7R9avz9X1U:t3ghQSAoNy8:V_sGLiP latest?d=qj6IDK7rITs latest?i=u7R9avz9X1U:t3ghQSAoNy8:gIN9vFwu7R9avz9X1U
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments