Timer
A timer for tracking countdown durations with pause/resume functionality.
Constructor
-
Timer(duration: float) → Timer
A timer for tracking countdown durations with pause/resume functionality.
Properties
| Name | Description | Type |
|---|---|---|
done | bool: True if the timer has finished counting down, False otherwise. | bool |
time_remaining | float: The remaining time in seconds before the timer completes. | float |
elapsed_time | float: The time elapsed since the timer was started, in seconds. | float |
progress | float: The completion progress of the timer as a value between 0.0 and 1.0. | float |
Methods
Start
start() → NoneStart or restart the timer countdown.
This begins the countdown from the full duration. If the timer was previously started, this will reset it back to the beginning.
Pause
pause() → NonePause the timer countdown.
The timer will stop counting down but retain its current state. Use resume() to continue the countdown from where it was paused. Has no effect if the timer is not started or already paused.
Resume
resume() → NoneResume a paused timer countdown.
Continues the countdown from where it was paused. Has no effect if the timer is not started or not currently paused.
Reset
reset() → NoneReset the timer to its initial state.
Stops the timer and resets it back to its initial, unstarted state.
The timer can be started again with start() after being reset.