File tree Expand file tree Collapse file tree 1 file changed +24
-4
lines changed
Expand file tree Collapse file tree 1 file changed +24
-4
lines changed Original file line number Diff line number Diff line change 1111import winsound
1212import pyglet
1313
14- if __name__ == '__main__' :
15- hh = input ('What hour do you want to wake up (0-23)? ' )
16- mm = input ('What minute do you want to wake up (0-59)? ' )
17-
14+ def play (hh , mm ):
1815 not_alarmed = 1
1916
2017 while (not_alarmed ):
2724 pyglet .app .run ()
2825 not_alarmed = 0 # stop the loop
2926
27+ if __name__ == '__main__' :
28+
29+ print """
30+ 1. Play sound after X minutes
31+ 2. Play sound at an exact time
32+ """
33+ choice = input ('What do you want to do? ' )
34+
35+ if choice == 1 :
36+ mins = input ('How many minutes from now? ' )
37+ hh_from_now = mins / 60 # if minutes > 60, this will adjust the hours
38+ mm_from_now = mins % 60 # and then the minutes
39+ cur_time = list (time .localtime ()) # get the time right now
40+ hour = cur_time [3 ] # find the current hour
41+ minute = cur_time [4 ] # and the current minute
42+ hh = (hour + hh_from_now ) % 24 # cycle through the clock if hh > 24
43+ mm = (minute + mm_from_now ) % 60 # cycle through the clock if mm > 60
44+ play (hh , mm )
45+ elif choice == 2 :
46+ hh = input ('What hour do you want to wake up (0-23)? ' )
47+ mm = input ('What minute do you want to wake up (0-59)? ' )
48+ play (hh , mm )
49+
You can’t perform that action at this time.
0 commit comments