Skip to content

Commit d96edc1

Browse files
committed
feat: Added alarms bot
1 parent 0eec497 commit d96edc1

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

Alarm Bot/main.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
from tkinter import *
2+
import datetime
3+
import time
4+
import winsound
5+
from threading import *
6+
7+
root = Tk()
8+
root.geometry("400x200")
9+
10+
def Threading():
11+
t1=Thread(target=alarm)
12+
t1.start()
13+
14+
def alarm():
15+
while True:
16+
set_alarm_time = f"{hour.get()}:{minute.get()}:{second.get()}"
17+
time.sleep(1)
18+
current_time = datetime.datetime.now().strftime("%H:%M:%S")
19+
print(current_time,set_alarm_time)
20+
21+
if current_time == set_alarm_time:
22+
print("Time to Wake up")
23+
winsound.PlaySound("sound.wav",winsound.SND_ASYNC)
24+
25+
Label(root,text="Alarm Clock",font=("Helvetica 20 bold"),fg="red").pack(pady=10)
26+
Label(root,text="Set Time",font=("Helvetica 15 bold")).pack()
27+
28+
frame = Frame(root)
29+
frame.pack()
30+
31+
hour = StringVar(root)
32+
hours = ('00', '01', '02', '03', '04', '05', '06', '07',
33+
'08', '09', '10', '11', '12', '13', '14', '15',
34+
'16', '17', '18', '19', '20', '21', '22', '23', '24'
35+
)
36+
hour.set(hours[0])
37+
38+
hrs = OptionMenu(frame, hour, *hours)
39+
hrs.pack(side=LEFT)
40+
41+
minute = StringVar(root)
42+
minutes = ('00', '01', '02', '03', '04', '05', '06', '07',
43+
'08', '09', '10', '11', '12', '13', '14', '15',
44+
'16', '17', '18', '19', '20', '21', '22', '23',
45+
'24', '25', '26', '27', '28', '29', '30', '31',
46+
'32', '33', '34', '35', '36', '37', '38', '39',
47+
'40', '41', '42', '43', '44', '45', '46', '47',
48+
'48', '49', '50', '51', '52', '53', '54', '55',
49+
'56', '57', '58', '59', '60')
50+
minute.set(minutes[0])
51+
52+
mins = OptionMenu(frame, minute, *minutes)
53+
mins.pack(side=LEFT)
54+
55+
second = StringVar(root)
56+
seconds = ('00', '01', '02', '03', '04', '05', '06', '07',
57+
'08', '09', '10', '11', '12', '13', '14', '15',
58+
'16', '17', '18', '19', '20', '21', '22', '23',
59+
'24', '25', '26', '27', '28', '29', '30', '31',
60+
'32', '33', '34', '35', '36', '37', '38', '39',
61+
'40', '41', '42', '43', '44', '45', '46', '47',
62+
'48', '49', '50', '51', '52', '53', '54', '55',
63+
'56', '57', '58', '59', '60')
64+
second.set(seconds[0])
65+
66+
secs = OptionMenu(frame, second, *seconds)
67+
secs.pack(side=LEFT)
68+
69+
Button(root,text="Set Alarm",font=("Helvetica 15"),command=Threading).pack(pady=20)
70+
root.mainloop()

0 commit comments

Comments
 (0)