Scheduler
- class moderngl_window.utils.scheduler.Scheduler(timer: BaseTimer)[source]
Bases:
object- cancel(event_id: int, delay: float = 0) None[source]
Cancel a previously scheduled event.
- Parameters:
event_id (int) – event to be canceled
delay (float, optional) – delay before canceling the event. Defaults to 0.
- run_at(action: Callable[[Any], Any], time: float, *, priority: int = 1, arguments: tuple[Any, ...] = (), kwargs: dict[Any, Any] = {}) int[source]
Schedule a function to be executed at a certain time.
- Parameters:
action (callable) – function to be called.
time (float) – epoch time at which the function should be called.
priority (int, optional) – priority for this event, lower is more important. Defaults to 1.
arguments (tuple, optional) – arguments for the action. Defaults to ().
kwargs (dict, optional) – keyword arguments for the action. Defaults to dict().
- Returns:
event id that can be canceled.
- Return type:
int
- run_every(action: Callable[[Any], Any], delay: float, *, priority: int = 1, initial_delay: float = 0.0, arguments: tuple[Any, ...] = (), kwargs: dict[Any, Any] = {}) int[source]
Schedule a recurring function to be called every delay seconds after a initial delay.
- Parameters:
action (callable) – function to be called.
delay (float) – delay in seconds.
priority (int, optional) – priority for this event, lower is more important. Defaults to 1.
initial_delay (float, optional) – initial delay in seconds before executing for the first time.
arguments (Defaults to 0.) – arguments for the action. Defaults to ().
kwargs (dict, optional) – keyword arguments for the action. Defaults to dict().
- Returns:
event id that can be canceled.
- Return type:
int
- run_once(action: Callable[[Any], Any], delay: float, *, priority: int = 1, arguments: tuple[Any, ...] = (), kwargs: dict[Any, Any] = {}) int[source]
Schedule a function for execution after a delay.
- Parameters:
action (callable) – function to be called.
delay (float) – delay in seconds.
priority (int, optional) – priority for this event, lower is more important. Defaults to 1.
arguments (tuple, optional) – arguments for the action. Defaults to ().
kwargs (dict, optional) – keyword arguments for the action. Defaults to dict().
- Returns:
event id that can be canceled.
- Return type:
int