pygame2.sdl.time – SDL time handling and measurement wrapper module

SDL time handling and measurement wrapper module.

Module Functions

pygame2.sdl.time.add_timer(interval, callable[, data]) → CObject

Adds a timer callback to be called periodically.

Adds a timer callback to be called periodically using the specified interval. callable can be any callable objet, method or function. On invocation, the optional data will be passed to the callable. If data is a sequence, each item of it will be passed as single argument to the callable.

This will return an CObject that acts as unique id for the timer callback.

Note

Timer callbacks will be invoked from a seperate thread, if the underlying SDL library can use threads. In those cases, the invoked callback will lock the interpreter instance, execute and release the lock. This in turn means that your callback must take care of not locking itself in order to wait for another function or thread to be executed within the same interpreter instance. Otherwise you can run into a classic dead lock situation.

Any added timer will be removed automatically on calling quit().

pygame2.sdl.time.delay(time) → None

Delays the execution for a specific time.

Delays the program execution for a specific time. The time is expressed in milliseconds.

Note

This does not require init() to be called before.

pygame2.sdl.time.get_ticks() → long

Gets the number of milliseconds since the initialization of the underlying SDL library.

Gets the number of milliseconds since the initialization of the underlying SDL library. The value will wrap if the program runs for more than ~49 days.

pygame2.sdl.time.init() → None
Initializes the timer subsystem of the SDL library.
pygame2.sdl.time.quit() → None

Shuts down the timer subsystem of the SDL library.

After calling this function, you should not invoke any class, method or function related to the timer subsystem as they are likely to fail or might give unpredictable results.

Note

Any timer set by set_timer() or add_timer() will be removed automatically on calling quit().

pygame2.sdl.time.remove_timer(timerobj) → None

Removes a previously added timer callback.

Removes a previously added timer callback and throws an exception, if the passed object is not a matching timer object.

pygame2.sdl.time.was_init() → bool
Returns, whether the timer subsystem of the SDL library is initialized.