Skip to content

FF: CountdownTimer init use reset instead of add for initial time#5609

Merged
peircej merged 1 commit intopsychopy:devfrom
gtosh4:bugfix/countdowntimer_warning
Jun 21, 2023
Merged

FF: CountdownTimer init use reset instead of add for initial time#5609
peircej merged 1 commit intopsychopy:devfrom
gtosh4:bugfix/countdowntimer_warning

Conversation

@gtosh4
Copy link
Contributor

@gtosh4 gtosh4 commented Jun 1, 2023

Following the example & documentation,

timer = core.CountdownTimer(5)

would cause the warning to show

WARNING We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use ['sounddevice', 'PTB', 'pyo', 'pygame'] (in that order).

How I found it (if that's at all useful) is to replace the Clock.add function to raise an exception to get the traceback.

def newAdd(self, x):
    raise Exception("Clock.add is deprecated")

core.Clock.add = newAdd

which resulted in the traceback:

  File "XXX\experiment1.py", line 330, in testF
    timer = core.CountdownTimer(2)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\clock.py", line 226, in __init__
    self.add(start)
  File "XXX\experiment1.py", line 30, in newAdd
    raise Exception("Clock.add is deprecated")

While I was there, I also simplified the CountdownTimer.reset() function a little.

@gtosh4 gtosh4 changed the title CountdownTimer init use reset instead of add for initial time FF: CountdownTimer init use reset instead of add for initial time Jun 1, 2023
@gtosh4 gtosh4 force-pushed the bugfix/countdowntimer_warning branch from 8e10900 to a14454e Compare June 1, 2023 22:37
@peircej peircej merged commit e73b8d8 into psychopy:dev Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants