Better alarm
I was thinking that the last program I made wasn't a good method of doing it, so I changed it. This time around, the program takes in a time in 24 hour format, in the form "HH:MM:SS". It then adds it to a list of those values, so that it can go through them and see if the current time is a time where an alarm needs to go off. If it is, it shows the notification, then removes that value from the list. If the list is empty, the program terminates. The current program doesn't allow for multiple inputs into the alarm's list, because the CLI will stop the program's progress if not given an input. Basically, the program is set to be ready for graphics integration.
from datetime import *
import win10toast
alarm_time = []
toast = win10toast.ToastNotifier()
alarm_time.append(input("Enter the time for the alarm, in the form HH:MM:SS in 24 hour time: "))
print(alarm_time[0])
while True:
time = datetime.now().strftime("%H:%M:%S")
i = 0
length = len(alarm_time)
while i != length:
if time == alarm_time[i]:
toast.show_toast("Alarm", "Alarm for time " + time)
del alarm_time[i]
i += 1
if not alarm_time:
break
Comments
Post a Comment