-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalarm.py
77 lines (61 loc) · 2.39 KB
/
alarm.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
#Alarm clock using Python Tkinter module
from tkinter import *
from tkinter import ttk
import time
from playsound import playsound
from pydub import AudioSegment
from pydub.playback import play
#import os
#def main():
root = Tk()
root.title("Alarm clock")
def SubmitButton():
label3 = Label(root, text = "", font = ('calibri', 12), foreground = 'white', background = 'sky blue')
label4 = Label(root, text = "", font = ('calibri', 12), foreground = 'white', background = 'sky blue')
AlarmTime= entry1.get()
Message1()
#label2.config(text ="The Alarm will Ring at {} ".format(AlarmTime)) #delayed in execution
CurrentTime = time.strftime("%H:%M")
label3.config(text = "the alarm time is: {}".format(AlarmTime))
label3.pack()
#label2.config(text="")
while AlarmTime != CurrentTime:
#label2.config(text ="The Alarm will Ring at {} ".format(AlarmTime))
CurrentTime = time.strftime("%H:%M")
time.sleep(1)
if AlarmTime == CurrentTime:
label4.config(text = "now Alarm Musing Playing")
#os.system("omxplayer alarm-music.mp3")
label2.config(text = "Alarm music playing...")
sound = AudioSegment.from_wav('alarm-music.wav')
play(sound)
# playsound('alarm-music.wav')
# pygame.mixer.Sound.play(sound)
# pygame.mixer.music.stop()
# you can also put the path of the mp3 or wav file if it didn't work
#label5 = Label(title= 'Alarm Message', message= "{}".format(entry2.get()))
#label5.pack()
def Message1():
AlarmTimeLable= entry1.get()
label2.config(text="the Alarm time is Counting...")
label2.config(text= "the Alarm will ring at {}".format(AlarmTimeLable))
#messagebox.showinfo(title = 'Alarm clock', message = 'Alarm will Ring at {}'.format(AlarmTimeLable))
#frame1 = ttk.Frame(root)
#frame1.pack()
#frame1.config(height = 100, width = 100)
label1= ttk.Label(root,text = "Enter the Alarm time :")
label1.pack()
entry1 = ttk.Entry(root, width = 30)
entry1.pack()
entry1.insert(3,"example - 13:15")
labelAlarmMessage= ttk.Label(root, text="Alarm Message:")
labelAlarmMessage.pack()
entry2= ttk.Entry(root, width=30)
entry2.pack()
button1= ttk.Button(root, text= "submit", command=SubmitButton)
button1.pack()
#this Label2 will show the Last Alarm Time
label2= ttk.Label(root)
label2.pack()
#label2.config(text="hello")
root.mainloop()