Package: count-timer
count-timerA class implementing a counting-up/counting-down timerInstallation$ pip install count-timerDemoThis 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.pyOnce 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.APICountTimer(duration: float)Creates a counting timer, with configurable duration (seconds). The timer starts at timet=0, and counts up using the system clock until it hitst=duration. At that time, theexpiredproperty is set toTrue. Note that the counter continues incrementing beyond the expiration time.Ifdurationis set to zero (which is the default), the timer never expires and continues to count forever.The timer can be paused using thepause()method. When paused, the timer stops incrementing. When the clock is resumed again (using theresume()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 theremainingproperty instead ofelapsed.┌─────────────────────────────────────────────────────────────────────────────────────┐
│                      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 startedpaused:bool
Whether or not the timer's countup has been pausedrunning: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 exceededstart():start() -> None
Starts the timer, counting up indefinitelypause():pause() -> None
Pauses the timer; the countup is stopped until resumedresume():resume() -> None
Resumes / unpauses the timer - when the timer is resumed, the countdown starts from where it was when pausedreset():reset() -> None
Puts the timer back in its original state when first created (paused / not yet started)