Skip to content

task

pdwidgets.task

Scheduled repeating tasks for :class:Display.

Task(callback, delay)

A task that runs a callback function after a specified delay. Used by the Display object to run tasks at regular intervals, such as refreshing the display or updating the clock.

Parameters:

Name Type Description Default
callback callable

The function to run.

required
delay int

The delay in milliseconds before running the callback.

required
Usage

def my_callback(): print("Hello, world!")

task = Task(my_callback, 1000) # Run my_callback every second display.add_task(task)

run(t)

Run the callback function and set the next run time.

Parameters:

Name Type Description Default
t int

The current time in milliseconds.

required