-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalarm_app.py
147 lines (81 loc) · 2.94 KB
/
alarm_app.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
"""
Created by *Abdullah EL-Yamany*
Channal => alba4mbarmg - الباشميرمج
Video Link ==>> https://youtu.be/_qMGOoyL8zA
note => Design and program Alarm App useing python language (Tkinter)
"""
#==========================
from tkinter import *
import datetime
import time
import winsound
import threading
def Threading():
t1 = threading.Thread(target=alarm)
t1.start()
def alarm():
while True:
if hour.get() == minute.get() == second.get() == "00" :
state.config(text="Please, Select Time!", bg="red")
break
else:
state.config(text="Please, Select Time!", bg="green")
userTime = f"{hour.get()}:{minute.get()}:{second.get()}"
time.sleep(1)
current_time = datetime.datetime.now().strftime("%H:%M:%S")
if userTime == current_time :
state.config(text="Time To Wake Up!", bg="black")
winsound.PlaySound(
"Alarm.mp3"
)
hour.set(hours[0])
minute.set(minutes[0])
second.set(seconds[0])
break
#--------------------------------- Gui Window ------------------------------#
alarm_app = Tk() # Create the Window App
alarm_app.geometry('700x450') # Size Wimdow in PC
alarm_app.title("Alarm App") # Title App in PC
icon_frame = PhotoImage(file=r"img/icon.png") # Icon App in PC
alarm_app.iconphoto(False, icon_frame)
app_title = Label(alarm_app, text="Alarm Clock", font=("Century 30 bold"), bg="black", fg="white")
app_title.pack(fill=X)
set_time = Label(alarm_app, text="Set Time", font=("Century 24"))
set_time.pack(pady=20)
#=========== Frame of [Hours, Min, Second]
frame = Frame(alarm_app)
frame.pack()
#---------- Hours --------#
hour = StringVar(alarm_app)
hours = []
for i in range(25):
hours.append(str(i).zfill(2))
hours_menu = OptionMenu(frame, hour, *hours)
hours_menu.pack(side=LEFT)
hours_menu.config(font=("Century 13"), width=5, background="white")
hour.set(hours[0])
#---------- Minutes --------#
minute = StringVar(alarm_app)
minutes = []
for i in range(61):
minutes.append(str(i).zfill(2))
mins_menu = OptionMenu(frame, minute, *minutes)
mins_menu.pack(side=LEFT)
mins_menu.config(font=("Century 13"), width=5, background="white")
minute.set(minutes[0])
#---------- Seconds --------#
second = StringVar(alarm_app)
seconds = []
for i in range(61):
seconds.append(str(i).zfill(2))
secs_menu = OptionMenu(frame, second, *seconds)
secs_menu.pack(side=LEFT)
secs_menu.config(font=("Century 13"), width=5, background="white")
second.set(seconds[0])
#------------ Botton To Start App ------------#
btn = Button(alarm_app, text="Start Alarm", font=("Century 18 bold"), bg="blue", fg="white", command=Threading)
btn.pack(pady=50)
#------ ----#
state = Label(alarm_app, font=("Century 10 bold"), fg="white")
state.pack()
alarm_app.mainloop()