-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.py
64 lines (46 loc) · 1.82 KB
/
sample.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
from tkinter import *
import datetime
import time
import winsound
def alarm(set_alarm_timer):
while True:
time.sleep(1)
current_time = datetime.datetime.now()
now = current_time.strftime("%H:%M:%S")
date = current_time.strftime("%d/%m/%Y")
print("The Set Date is:",date)
print(now)
if now == set_alarm_timer:
print("Time to Wake up")
winsound.PlaySound("sound.wav",winsound.SND_ASYNC)
break
def actual_time():
set_alarm_timer = f"{hour.get()}:{min.get()}:{sec.get()}"
alarm(set_alarm_timer)
def times():
string = time.strftime('%H:%M:%S %p')
lbl.config(text=string)
lbl.after(1000, times)
clock = Tk()
clock.title("DataFlair Alarm Clock")
clock.geometry("400x300")
clock.resizable(0,0)
lbl = Label(clock, font=('calibri', 40, 'bold'),
background='purple',
foreground='white')
time_format=Label(clock, text= "Enter time in 24 hour format!", fg="red",bg="black",font="Arial").place(x=60,y=200)
setYourAlarm = Label(clock,text = "When to alarm",fg="blue",relief = "solid",font=("Helevetica",11,"bold")).place(x=0, y=110)
# The Variables we require to set the alarm(initialization):
hour = StringVar()
min = StringVar()
sec = StringVar()
#Time required to set the alarm clock:
hourTime= Entry(clock,textvariable = hour,bg = "green",width = 15).place(x=110,y=110)
minTime= Entry(clock,textvariable = min,bg = "green",width = 15).place(x=150,y=110)
secTime= Entry(clock,textvariable = sec,bg = "green",width = 15).place(x=200,y=110)
lbl.pack(anchor='center')
times()
#To take the time input by user:
submit = Button(clock,text = "Set Alarm",fg="red",width = 10,command = actual_time).place(x =110,y=150)
clock.mainloop()
#Execution of the window.