Skip to main content

PyTimer is a lightweight and easy-to-use Python package designed to provide countdown timer functionality. It offers a simple class-based approach to manage countdowns, making it perfect for various use cases such as timing events, tracking intervals, or managing delays in scripts and applications.

Project description

PyTimer2

PyTimer2 is a simple Python countdown timer package that offers start, pause, resume, and stop functionalities. This tool is perfect for managing timed tasks, creating simple scheduling systems, or integrating into larger applications where precise countdown control is required.

Downloads

Features

  • Start Countdown: Initiate a countdown for a specified duration.
  • Pause Countdown: Pause the countdown at any moment without losing the current time.
  • Resume Countdown: Resume the countdown from where it was paused.
  • Stop Countdown: Completely stop the countdown and reset the timer.
  • Non-Blocking Execution: Runs in a separate thread, allowing your main application to continue running without interruption.

Installation

You can install PyTimer directly from GitHub or from PyPI:

# Install pytimer2
pip install pytimer2

# Usage
from pytimer2 import Timer
import time

# Create a Timer instance
timer = Timer()

# Start the countdown with a duration of 500 seconds
timer.start_countdown(duration=500)

# Access the current countdown value
print(f"Current countdown: {timer.get_countdown()} seconds")

# Let it run for a few seconds and then pause
time.sleep(3)
timer.pause_countdown()
print(f"Countdown paused: {timer.get_countdown()} seconds")

# Wait and then resume the countdown
time.sleep(5)
print(f"Countdown still paused: {timer.get_countdown()} seconds")
timer.resume_countdown()
print("Timer resumed...")

# Run for a few more seconds
time.sleep(2)
print(f"Countdown resumed and current time: {timer.get_countdown()} seconds")

# Stop the countdown
timer.stop_countdown()
print(f"Countdown stopped at: {timer.get_countdown()} seconds")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytimer2-0.2.4.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

pytimer2-0.2.4-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page