Created
December 19, 2021 21:51
-
-
Save CodeMaster7000/0dd2ed2a5f21c1153424b7b1b31f6e56 to your computer and use it in GitHub Desktop.
An Alarm Clock coded in Python 3. Run 'Alarm Clock.py' in a terminal if you have Python 3.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Time 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) | |
clock = Tk() | |
clock.title("Alarm Clock") | |
clock.geometry("300x200") | |
time_format=Label(clock, text= "Enter time in the 24-hour format!", fg="green",font="Arial").place(x=36,y=120) | |
addTime = Label(clock,text = "Hr Min Sec",font=("Calibri",13,"normal")).place(x = 110) | |
setYourAlarm = Label(clock,text = "Alarm Time:",fg="blue",font=("Helevetica",11,"bold")).place(x=15, y=29) | |
hour = StringVar() | |
min = StringVar() | |
sec = StringVar() | |
hourTime= Entry(clock,textvariable = hour,bg = "pink",width = 15).place(x=110,y=30) | |
minTime= Entry(clock,textvariable = min,bg = "pink",width = 15).place(x=150,y=30) | |
secTime = Entry(clock,textvariable = sec,bg = "pink",width = 15).place(x=200,y=30) | |
submit = Button(clock,text = "Set Alarm",fg="red",width = 10,command = actual_time).place(x =110,y=70) | |
clock.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment