Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

alarm clock python

#Importing all the necessary libraries to form the alarm clock:
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 Set Date 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("DataFlair Alarm Clock")
clock.geometry("400x200")
time_format=Label(clock, text= "Enter time in 24 hour format!", fg="red",bg="black",font="Arial").place(x=60,y=120)
addTime = Label(clock,text = "Hour  Min   Sec",font=60).place(x = 110)
setYourAlarm = Label(clock,text = "When to wake you up",fg="blue",relief = "solid",font=("Helevetica",7,"bold")).place(x=0, y=29)
# The Variables we require to set the alarm(initialization):
hour = StringVar()
min = StringVar()
sec = StringVar()
#Time required to set the alarm clock:
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)
#To take the time input by user:
submit = Button(clock,text = "Set Alarm",fg="red",width = 10,command = actual_time).place(x =110,y=70)
clock.mainloop()
#Execution of the window.
Comment

PREVIOUS NEXT
Code Example
Python :: python string to xml 
Python :: python seconds counter 
Python :: how to get the index of a value in pandas dataframe 
Python :: get dictionary in array python by value 
Python :: how to end the python program 
Python :: python how often element in list 
Python :: pyqt5 qtwebenginewidgets not found 
Python :: pandas read csv read all rows except one 
Python :: how to remove data from mongo db python 
Python :: use of the word bruh over time 
Python :: convert time zone pandas 
Python :: pandas read csv unamed:o 
Python :: pandas normalize df 
Python :: arctan in python 
Python :: how to obtain the content of brackets 
Python :: how to convert 24 hours to 12 hours in python 
Python :: list to set keep order python 
Python :: delete row from dataframe python 
Python :: how to add scrollbar to listbox in tkinter 
Python :: convert list to array python 
Python :: get list of users django 
Python :: python check if all dictionary values are False 
Python :: unpack dictionaryp 
Python :: django import timezone 
Python :: pandas drop columns by index 
Python :: plt close all 
Python :: django make migrations 
Python :: actual keystroke python 
Python :: django session expire time 
Python :: normalize = true pandas 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =