-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (34 loc) · 1.23 KB
/
main.py
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
43
import tkinter as tk
import time
def set_alarm():
global alarm_time
alarm_time = alarm_entry.get()
alarm_label.config(text="Alarm set for " + alarm_time,font=("Helvetica", 40))
def update_time():
current_time = time.strftime('%H:%M:%S')
time_label.config(text=current_time)
if alarm_time and current_time[:5] == alarm_time[:5]:
alarm_label.config(text="ALARM!", font=("Helvetica", 40))
time_label.after(1000, update_time)
# Create GUI window
window = tk.Tk()
window.title("Alarm Clock")
window.config(bg='lightgreen')
# Create GUI components
time_label = tk.Label(window, text="", font=("Helvetica", 48))
alarm_label = tk.Label(window, text="", font=("Helvetica", 48))
my_label=tk.Label(window,text="Enter as Hr:min:Sec",font=("Helvetica", 24))
alarm_entry = tk.Entry(window, font=("Helvetica", 14))
set_alarm_button = tk.Button(window, text="Set Alarm",font=("Helvetica", 24), command=set_alarm)
# Place components in the window
time_label.pack(pady=20)
alarm_label.pack()
my_label.pack(pady=20)
alarm_entry.pack(pady=10)
set_alarm_button.pack()
# Initialize alarm_time
alarm_time = ""
# Start the clock update loop
update_time()
# Start GUI event loop
window.mainloop()