simpleguics2pygame — timer
simpleguics2pygame module: simpleguics2pygame/timer.
Class Timer.
Don’t require Pygame.
Piece of SimpleGUICS2Pygame. https://bitbucket.org/OPiMedia/simpleguics2pygame
- license
GPLv3 — Copyright (C) 2015, 2020 Olivier Pirson
- author
Olivier Pirson — http://www.opimedia.be/
- version
May 20, 2020
- class SimpleGUICS2Pygame.simpleguics2pygame.timer.Timer(interval: Union[int, float], timer_handler: Callable[[], Any])[source]
Timer similar to SimpleGUI Timer of CodeSkulptor.
Don’t require Pygame.
- __init__(interval: Union[int, float], timer_handler: Callable[[], Any]) None [source]
Set a time.
Don’t use directly, use create_timer().
- Parameters
interval – int or float > 0
timer_handler – function () -> *
- __weakref__
list of weak references to the object (if defined)
- classmethod _stop_all() None [source]
Stop all timers.
(Not available in SimpleGUI of CodeSkulptor.)
Side effect: Empty Timer._timers_running.
- get_interval() Union[int, float] [source]
Return the interval of this timer.
(Maybe available in SimpleGUI of CodeSkulptor but not in CodeSkulptor documentation!)
- Returns
(int or float) > 0
- is_running() bool [source]
If this timer is running then return True, else return False.
- Returns
bool
- start() None [source]
Start this timer.
Warning
With SimpleGUICS2Pygame,
Frame.start()
is blocking untilFrame.stop()
execution or closing window. So timers must be started before, and states must be initialized before. (Or maybe after by a handler function.)(Side effect: Add id(self): self in Timer._timers_running.)
- SimpleGUICS2Pygame.simpleguics2pygame.timer.create_timer(interval: Union[int, float], timer_handler: Callable[[], Any]) SimpleGUICS2Pygame.simpleguics2pygame.timer.Timer [source]
Create and return a timer that will execute the function timer_handler every interval milliseconds.
The first execution of time_handler will take place after the first period.
(The timer can be started by Timer.start().)
- Parameters
interval – int or float > 0
timer_handler – function () -> *
- Returns
Timer
- SimpleGUICS2Pygame.simpleguics2pygame.timer.__all__ = ('Timer', 'create_timer')
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
[source]