Skip to content

Instantly share code, notes, and snippets.

@altilunium
Last active October 2, 2024 14:42
Show Gist options
  • Save altilunium/2726cdb0866b87062f1c5f47ff0a3e44 to your computer and use it in GitHub Desktop.
Save altilunium/2726cdb0866b87062f1c5f47ff0a3e44 to your computer and use it in GitHub Desktop.
Python timer, with Windows Notification
# pip install win10toast
import time
from win10toast import ToastNotifier
# Function to show Windows notification
def show_notification(title, message):
toaster = ToastNotifier()
toaster.show_toast(title, message, duration=10) # duration is in seconds
# Function to start a timer
def start_timer(duration_seconds):
print(f"Timer started for {duration_seconds} seconds.")
time.sleep(duration_seconds)
show_notification("Timer Complete", "Your timer has finished!")
if __name__ == "__main__":
# Set timer duration in seconds
timer_duration = 10 # example: 10 seconds
start_timer(timer_duration)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment