Skip to content

Commit b88d7fe

Browse files
committed
Initial
0 parents  commit b88d7fe

20 files changed

+814
-0
lines changed

.idea/TryCatch-Projects.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects-1/Alarm-Clock.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
from tkinter import *
3+
import datetime
4+
import time
5+
from playsound import playsound
6+
7+
8+
def alarm(set_alarm_timer):
9+
while True:
10+
time.sleep(1) # Print current time after every 1 second
11+
current_time = datetime.datetime.now()
12+
now = current_time.strftime("%H:%M:%S")
13+
date = current_time.strftime("%d/%m/%Y")
14+
print("The Set Date is:", date)
15+
print(now)
16+
if now == set_alarm_timer:
17+
print("Time to Wake up")
18+
19+
play = 0
20+
while play != 10: # This will ring alarm for 10 seconds
21+
playsound(
22+
"/home/harsh/Harsh/Python/TryCatch-Projects/Projects-1/sound.wav")
23+
play += 1
24+
print("Set alarm again")
25+
return
26+
27+
28+
def actual_time():
29+
set_alarm_timer = f"{hour.get()}:{min.get()}:{sec.get()}"
30+
alarm(set_alarm_timer)
31+
32+
33+
clock = Tk()
34+
clock.title("TryCatch Alarm Clock")
35+
clock.geometry("500x250")
36+
get_up = Label(clock, text="At what time do you wanna get up?",
37+
fg="Blue", font=("Arial", 20, 'bold')).place(x=35, y=10)
38+
39+
time_format = Label(clock, text="Enter the time in 24 hr format",
40+
fg="Blue", bg="black", font=("Arial", 15, 'bold')).place(x=115, y=200)
41+
addTime = Label(clock, text="Hour Min Sec", font=60).place(x=150, y=90)
42+
43+
# The Variables we require to set the alarm(initialization):
44+
hour = StringVar()
45+
min = StringVar()
46+
sec = StringVar()
47+
48+
hourTime = Entry(clock, textvariable=hour, bg="powderblue",
49+
width=15).place(x=150, y=120)
50+
minTime = Entry(clock, textvariable=min, bg="powderblue",
51+
width=15).place(x=190, y=120)
52+
secTime = Entry(clock, textvariable=sec, bg="powderblue",
53+
width=15).place(x=240, y=120)
54+
55+
set_alarm = Button(clock, text="Set Alarm", fg="green", activebackground="grey", activeforeground="darkgreen", width=10, font=(
56+
"Arial", 15, 'bold'), command=actual_time).place(x=200, y=150)
57+
58+
59+
clock.mainloop()

0 commit comments

Comments
 (0)