Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-08-2020, 07:24 PM   #1
LQ Newbie
Registered: Dec 2014
Posts: 15

Rep: Reputation: Disabled
[solved] Python - force display update?

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?

# one second decrement
def decrement():
    global EndTime, Repeat
    if StopIt.get() == True or Repeat > 5:
        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:
    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.


Last edited by Mik3e; 08-10-2020 at 11:56 AM.
Old 08-09-2020, 02:25 AM   #2
LQ Guru
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 9,756

Rep: Reputation: 4408Reputation: 4408Reputation: 4408Reputation: 4408Reputation: 4408Reputation: 4408Reputation: 4408Reputation: 4408Reputation: 4408Reputation: 4408Reputation: 4408
Pass False to playsound as a second argument. E.g.

playsound('/media/Avocet/Python/says.wav', False)
Old 08-09-2020, 11:06 AM   #3
LQ Newbie
Registered: Dec 2014
Posts: 15

Original Poster
Rep: Reputation: Disabled
Thanks dugan, however. The label refreshed but the sound didn't play and I got this error:

NotImplementedError: block=False cannot be used on this platform yet

So close and yet so far.

I'm using Mint. Is it implemented on others in the Debian/Ubuntu family? If so do you think I should bring this up with Mint?

Thanks again,
Old 08-10-2020, 11:55 AM   #4
LQ Newbie
Registered: Dec 2014
Posts: 15

Original Poster
Rep: Reputation: Disabled
I discovered that simpleaudio does not have this problem, and only takes one more line of code.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
I got error while installing python-tk python-psycopg2 python-twisted saili kadam Linux - Newbie 1 09-05-2015 03:03 AM
[SOLVED] No force feedback in wine game from a Logitech Driving Force GT ethoms Slackware 11 05-17-2014 09:23 AM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
python update - Unable to load GTK2 Python bindings: No module named gtk itpedersen Linux - Software 2 10-03-2008 03:44 AM
python: can you update the current shell from python? BrianK Programming 4 01-31-2008 12:18 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:34 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration