GUI ALARM CLOCK USING PYTHON
Source Code:-
01 02 03 04 05 06 07 08 09 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 | # ALARM CLOCK USING PYTHONfrom tkinter import *from datetime import datetimeimport timeimport winsoundroot = Tk()root.geometry("670x280+380+150")root.title("Alarm Clock using Python")root.config(bg = "gray")root.resizable(0, 0)def alarm(): while True: time.sleep(1) now = datetime.now() current_time = now.strftime("%H:%M:%S") my_alarm = f"{Hour.get()}:{Min.get()}:{Sec.get()}" H, M, S = now.hour, now.minute, now.second print(H,":",M,":",S) if current_time == my_alarm: print("Hello Buddy") winsound.Beep(2500, 1000) exit()Label(root, text = "GUI ALARM CLOCK", font = ("None 35 bold underline"), bg = "gray").place(x = 130, y = 20)Label(root, text = "Enter Time(24-Hour Format):", font = ("None 20 bold"), bg = "gray").place(x = 20, y = 120)Hour = IntVar()Hour.set("")Entry(root, textvariable = Hour, font = ("None 20 bold"), bg = "lightpink", width = 3).place(x = 420, y = 120)Label(root, text = ":", font = ("None 30 bold"), bg = "gray").place(x = 470, y = 110)Min = IntVar()Min.set("")Entry(root, textvariable = Min, font = ("None 20 bold"), bg = "lightpink", width = 3).place(x = 490, y = 120)Label(root, text = ":", font = ("None 30 bold"), bg = "gray").place(x = 540, y = 110)Sec = IntVar()Sec.set("")Entry(root, textvariable = Sec, font = ("None 20 bold"), bg = "lightpink", width = 3).place(x = 560, y = 120)Button(root, text = "Set Alarm", font = ("None 20 bold"), bg = "orange", bd = 5, command = alarm).place(x = 250, y = 190)root.mainloop() |
# ALARM CLOCK USING PYTHON
from tkinter import *
from datetime import datetime
import time
import winsound
root = Tk()
root.geometry("670x280+380+150")
root.title("Alarm Clock using Python")
root.config(bg = "gray")
root.resizable(0, 0)
def alarm():
while True:
time.sleep(1)
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
my_alarm = f"{Hour.get()}:{Min.get()}:{Sec.get()}"
H, M, S = now.hour, now.minute, now.second
print(H,":",M,":",S)
if current_time == my_alarm:
print("Hello Buddy")
winsound.Beep(2500, 1000)
root.destroy()
Label(root, text = "GUI ALARM CLOCK", font = ("None 35 bold underline"), bg = "gray").place(x = 130, y = 20)
Label(root, text = "Enter Time(24-Hour Format):", font = ("None 20 bold"), bg = "gray").place(x = 20, y = 120)
Hour = IntVar()
Hour.set("")
Entry(root, textvariable = Hour, font = ("None 20 bold"), bg = "lightpink", width = 3).place(x = 420, y = 120)
Label(root, text = ":", font = ("None 30 bold"), bg = "gray").place(x = 470, y = 110)
Min = IntVar()
Min.set("")
Entry(root, textvariable = Min, font = ("None 20 bold"), bg = "lightpink", width = 3).place(x = 490, y = 120)
Label(root, text = ":", font = ("None 30 bold"), bg = "gray").place(x = 540, y = 110)
Sec = IntVar()
Sec.set("")
Entry(root, textvariable = Sec, font = ("None 20 bold"), bg = "lightpink", width = 3).place(x = 560, y = 120)
Button(root, text = "Set Alarm", font = ("None 20 bold"), bg = "orange", bd = 5, command = alarm).place(x = 250, y = 190)
root.mainloop()

0 Comments