simpleguics2pygame — timer

simpleguics2pygame/timer (October 2nd, 2015)

Class Timer.

Don’t require Pygame.

Piece of SimpleGUICS2Pygame. https://bitbucket.org/OPiMedia/simpleguics2pygame

GPLv3 — Copyright (C) 2015 Olivier Pirson http://www.opimedia.be/

class SimpleGUICS2Pygame.simpleguics2pygame.timer.Timer(interval, timer_handler)[source]

Timer similar to SimpleGUI Timer of CodeSkulptor.

Don’t require Pygame.

__init__(interval, timer_handler)[source]

Set a time.

Don’t use directly, use create_timer().

Parameters:
  • interval – int or float > 0
  • timer_handler – function () -> *
__repr__()[source]

Return ‘<Timer object>’.

Returns:str
classmethod _stop_all()[source]

Stop all timers.

(Not available in SimpleGUI of CodeSkulptor.)

Side effect: Empty Timer._timers_running.

get_interval()[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()[source]

If this timer is running then return True, else return False.

Returns:bool
start()[source]

Start this timer.

Warning

With SimpleGUICS2Pygame, Frame.start() is blocking until Frame.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.)

stop()[source]

Stop this timer.

(Side effect: Remove id(self) of Timer. _timers_running.)

__weakref__

list of weak references to the object (if defined)

SimpleGUICS2Pygame.simpleguics2pygame.timer.create_timer(interval, timer_handler)[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']

list() -> new empty list list(iterable) -> new list initialized from iterable’s items

[source]