5
5
from datetime import datetime , timedelta
6
6
import winsound
7
7
8
+
8
9
class NotificationApp (tk .Tk ):
9
10
def __init__ (self ):
10
11
super ().__init__ ()
@@ -13,8 +14,10 @@ def __init__(self):
13
14
self .configure (bg = "black" )
14
15
15
16
style = ttk .Style (self )
16
- style .configure ("TLabel" , foreground = "white" , background = "black" , font = ("Helvetica" , 12 ))
17
- style .configure ("TButton" , foreground = "black" , background = "white" , font = ("Helvetica" , 12 ))
17
+ style .configure ("TLabel" , foreground = "white" ,
18
+ background = "black" , font = ("Helvetica" , 12 ))
19
+ style .configure ("TButton" , foreground = "black" ,
20
+ background = "white" , font = ("Helvetica" , 12 ))
18
21
19
22
self .label_days = ttk .Label (self , text = "Days:" )
20
23
self .label_days .pack (pady = 5 )
@@ -40,16 +43,19 @@ def __init__(self):
40
43
self .entry_seconds = ttk .Entry (self )
41
44
self .entry_seconds .pack ()
42
45
43
- self .label_message = ttk .Label (self , text = "Enter notification message:" )
46
+ self .label_message = ttk .Label (
47
+ self , text = "Enter notification message:" )
44
48
self .label_message .pack (pady = 5 )
45
49
46
50
self .entry_message = ttk .Entry (self )
47
51
self .entry_message .pack ()
48
52
49
- self .button_set = ttk .Button (self , text = "Set Notification" , command = self .schedule_notification )
53
+ self .button_set = ttk .Button (
54
+ self , text = "Set Notification" , command = self .schedule_notification )
50
55
self .button_set .pack (pady = 10 )
51
56
52
- self .label_time_left = ttk .Label (self , text = "Time left: 0 days, 0:00:00" )
57
+ self .label_time_left = ttk .Label (
58
+ self , text = "Time left: 0 days, 0:00:00" )
53
59
self .label_time_left .pack (pady = 5 )
54
60
55
61
def show_notification (self ):
@@ -60,7 +66,8 @@ def show_notification(self):
60
66
notification_window .geometry ("300x150" )
61
67
notification_window .configure (bg = "black" )
62
68
63
- notification_label = ttk .Label (notification_window , text = f"{ message } \n \n Current time: { now } " , font = ("Helvetica" , 12 ), foreground = "white" , background = "black" )
69
+ notification_label = ttk .Label (notification_window , text = f"{ message } \n \n Current time: { now } " , font = (
70
+ "Helvetica" , 12 ), foreground = "white" , background = "black" )
64
71
notification_label .pack (pady = 10 )
65
72
66
73
# Play notification sound
@@ -77,13 +84,15 @@ def get_delay_time(self):
77
84
seconds = int (self .entry_seconds .get ())
78
85
79
86
if days < 0 or hours < 0 or minutes < 0 or seconds < 0 :
80
- messagebox .showerror ("Error" , "All values must be non-negative." )
87
+ messagebox .showerror (
88
+ "Error" , "All values must be non-negative." )
81
89
return None
82
90
83
91
total_seconds = days * 86400 + hours * 3600 + minutes * 60 + seconds
84
92
return total_seconds
85
93
except ValueError :
86
- messagebox .showerror ("Error" , "Invalid input. Please enter numeric values." )
94
+ messagebox .showerror (
95
+ "Error" , "Invalid input. Please enter numeric values." )
87
96
return None
88
97
89
98
def schedule_notification (self ):
@@ -92,7 +101,8 @@ def schedule_notification(self):
92
101
return
93
102
94
103
self .button_set .config (state = tk .DISABLED )
95
- notification_thread = Thread (target = self ._wait_and_notify , args = (delay ,))
104
+ notification_thread = Thread (
105
+ target = self ._wait_and_notify , args = (delay ,))
96
106
notification_thread .start ()
97
107
98
108
def _wait_and_notify (self , delay ):
@@ -108,6 +118,7 @@ def _wait_and_notify(self, delay):
108
118
self .show_notification ()
109
119
self .button_set .config (state = tk .NORMAL )
110
120
121
+
111
122
if __name__ == "__main__" :
112
123
app = NotificationApp ()
113
124
app .mainloop ()
0 commit comments