mardi 24 avril 2018

Python Alarm Clock Doesn't Break

I tried to make a simple Alarm Clock without using Tkinter. The Alarm runs and starts a countdown of every second but when it gets to the set time that the Alarm is supposed to go off, it continues to run. How would I make the Alarm Break and open my web browser to play the selected song in mylines at the set time?

lines = open("Links.txt").read().splitlines()
mylines = random.choice(lines)
print(mylines)  


name = raw_input("Enter your name: ")

print("Hello, " + name)

alarm_hour = input("Enter the hour you want to wake up: ")
alarm_min = input("Enter the min of the hour you want to wake up: ")

print("You want to wake up at: {0:02}:{1:02}").format(alarm_hour, alarm_min)
alarm = Alarm(alarm_hour, alarm_min)
#print (time.strftime())
clock = time.strftime("%H:%M:%S")
while True:
    if clock != alarm:
    print "The time is: " + clock
    clock = time.strftime("%H:%M:%S")
    time.sleep(1)

    if alarm == clock:
    #webbrowser.open(newlist[pick])
        print "Alarm Now"
        webbrowser.open(mylines)
        break

Aucun commentaire:

Enregistrer un commentaire