Start counting if the timer is currently stopped.
Returns
Timer — Returns the same timer for chaining.Example
# Measure time in the calling flow
timer = Timer(auto_start=False)
timer.start()
wait(100)
print(timer.elapsed_ms())
Pause counting while preserving elapsed milliseconds.
Returns
Timer — Returns the same timer for chaining.Example
# Measure time in the calling flow
timer = Timer()
wait(100)
timer.pause()
print(timer.elapsed_ms())
Resume counting from paused state.
Returns
Timer — Returns the same timer for chaining.Example
# Measure time in the calling flow
timer = Timer()
timer.pause()
timer.resume()
wait(100)
print(timer.elapsed_ms())
Stop counting and keep elapsed milliseconds frozen.
Returns
Timer — Returns the same timer for chaining.Example
# Measure time in the calling flow
timer = Timer()
wait(100)
timer.stop()
print(timer.elapsed_ms())
Reset elapsed time to 0 while keeping the current running state.
Returns
Timer — Returns the same timer for chaining.Example
# Measure time in the calling flow
timer = Timer()
wait(100)
timer.reset()
print(timer.elapsed_ms())
Reset elapsed time to 0 and start counting immediately.
Returns
Timer — Returns the same timer for chaining.Example
# Measure time in the calling flow
timer = Timer(auto_start=False)
timer.restart()
wait(100)
print(timer.elapsed_ms())
Read total elapsed milliseconds.
Returns
Number — Elapsed milliseconds.
Example
# Measure time in the calling flow
timer = Timer()
wait(100)
print(timer.elapsed_ms())
Check whether elapsed time is greater than or equal to the provided milliseconds.
Returns
Boolean — true when elapsed time reached or exceeded the threshold.
Example
# Measure time in the calling flow
timer = Timer()
wait(500)
if timer.is_elapsed(500):
print("Elapsed")
Check whether the timer is currently counting.
Returns
Boolean — true when timer is counting.
Example
# Measure time in the calling flow
timer = Timer()
print(timer.is_running())
Check whether the timer is paused after being started.
Returns
Boolean — true when timer is paused.
Example
# Measure time in the calling flow
timer = Timer()
timer.pause()
print(timer.is_paused())