LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


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

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?

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

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

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

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

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,
Mike
 
Old 08-10-2020, 11:55 AM   #4
Mik3e
LQ Newbie
 
Registered: Dec 2014
Posts: 20

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

Mike
 
  


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:26 PM.

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