Skip to main content

count-timer

A class implementing a counting-up/counting-down timer

Installation

$ pip install count-timer

Demo

This is a rudimentary text-based demonstration of the count-down version of the CountTimer class. You can launch it directly:

$ demo

...or from Python:

$ python count_timer/demo_async.py

Once launched, the demo will prompt you to enter a duration (the count-down timer expiration value). The timer will begin counting down on the terminal. The time will transition to yellow when there is <10 sec before expiration, and red when there are <5 sec.

Pressing "q" will cause the timer to quit.

Pressing "r" will cause the timer to restart at the original duration.

The timer may be paused/resumed by pressing the space bar.

API

CountTimer(duration: float)

Creates a counting timer, with configurable duration (seconds). The timer starts at time t=0, and counts up using the system clock until it hits t=duration. At that time, the expired property is set to True. Note that the counter continues incrementing beyond the expiration time.

If duration is set to zero (which is the default), the timer never expires and continues to count forever.

The timer can be paused using the pause() method. When paused, the timer stops incrementing. When the clock is resumed again (using the resume() method), it continues from where it left off.

This counter/timer can be used as a "count-up" timer or a "count-down" timer. The default mode of interpretation is "up," but if you prefer a countdown time, simply look at the remaining property instead of elapsed.

┌─────────────────────────────────────────────────────────────────────────────────────┐
│                      count_timer.count_timer.CountTimer                             │
└─────────────────────────────────────────────────────────────────────────────────────┘
class CountTimer(duration=0):
    A counting timer (w/ optional expiry that can be started, paused, resumed and reset

    Configuration:
        duration: Number of seconds to elapse before expiration
                  (optional; default: 0 - indicates time never expires)

    Methods:
        start(): start the timer
        pause(): pause the timer
        resume(): resume the timer
        reset(): reset the timer to default (duration 0/paused/not started)

    Properties:
        paused: True if timer is paused
        running: True if timer is running
        duration: value of the 'duration' config param
        elapsed: time (sec) since timer was started
        remaining: time (sec) until timer expires

    Inspiration from https://stackoverflow.com/a/60027719/4402572

   def start(self):
       Start the timer.
   def pause(self):
       Pause the timer.
   def resume(self):
       Resume the timer.
   def reset(self, duration=0):

elapsed: float Time (seconds) since the timer was started

paused: bool Whether or not the timer's countup has been paused

running: bool Whether or not the timer is currently running (i.e. incrementing internally)

expired: bool Whether or not the timer's configured expiration value has been exceeded

start(): start() -> None Starts the timer, counting up indefinitely

pause(): pause() -> None Pauses the timer; the countup is stopped until resumed

resume(): resume() -> None Resumes / unpauses the timer - when the timer is resumed, the countdown starts from where it was when paused

reset(): reset() -> None Puts the timer back in its original state when first created (paused / not yet started)

Metadata

Release files for count-timer 0.3.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for count-timer 0.3.8
File Size Uploaded Provenance
count-timer-0.3.8.tar.gz 5.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for count-timer 0.3.8
File Interpreter ABI Platform
count_timer-0.3.8-py3-none-any.whl Python 3 none any Details

Total release size: 17.5 kB

Release files / count-timer-0.3.8.tar.gz

Download URL count-timer-0.3.8.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
03ab3ba3738eac50fb7000cad14b7ec7663f92c708b3ed5ff881f5ae3af5278b
BLAKE2b-256 checksum
How to use checksums
7e14d70ae7d676ff96e98970932a8db43e94c49505c1a9afbd445c4ca5ca4d8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.9

Release files / count_timer-0.3.8-py3-none-any.whl

Download URL count_timer-0.3.8-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9818a0f41f1adb5db99bbfa6ab346a1f73acdea9f0e95474081ec0032afd28a0
BLAKE2b-256 checksum
How to use checksums
947f6d28dee72cef3c98cc4034f22c4828a5637d0b467aaf249d244e9384eaf2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.9

Security for count-timer 0.3.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page