-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotification_System.py
More file actions
44 lines (32 loc) · 973 Bytes
/
Copy pathNotification_System.py
File metadata and controls
44 lines (32 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#using threading
from plyer import notification
import threading
interval = 60 * 60
def send_notification():
notification.notify(
title="💧 Drink Water Reminder",
message="Time to drink water and stay hydrated!",
timeout=10
)
threading.Timer(interval, send_notification).start()
send_notification()
#using scheduler
from plyer import notification
import sched
import time
# Create a scheduler
scheduler = sched.scheduler(time.time, time.sleep)
# Interval in seconds (e.g., 60*60 for 1 hour)
interval = 60 * 60
def send_notification():
notification.notify(
title="💧 Drink Water Reminder",
message="Time to drink water and stay hydrated!",
timeout=10
)
# Schedule the next notification
scheduler.enter(interval, 1, send_notification)
# Schedule the first notification
scheduler.enter(0, 1, send_notification)
# Start the scheduler
scheduler.run()