Last active
October 2, 2024 14:42
-
-
Save altilunium/2726cdb0866b87062f1c5f47ff0a3e44 to your computer and use it in GitHub Desktop.
Python timer, with Windows Notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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