Creating Alarm Clock using Python source code

Creating Alarm Clock using Python source code

In this article, We will be creating an Alarm Clock using Python. To Create an Alarm Clock Using Python we need Two Python libraries datetime and tkinter which help us to build the project using the current date and time. Apart from this, they also provide a user interface to set the alarm according to the user requirement in 24-hour format.

For creating this simple Alarm Clock project using Python, make sure you have Pycharm IDE installed on your computer if not install it.

Steps on How To Create An Alarm Clock Using Python.

Step 1: First, open Pycharm IDE and then create “Project Name” after creating the project name, click the “Create” button.
Step 2: Second, after creating the project name, “right click” on your project name and then click on “New” and then click on “Python File”.
Step 3: Third, after creating a Python file, name your Python file and then click “Enter”.
Step 4: Fourth, you need to copy and paste the below code into your Pycharm IDE

#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:
        current_time =
        now = current_time.strftime("%H:%M:%S")
        date = current_time.strftime("%d/%m/%Y")
        print("The Set Date is:",date)
        if now == set_alarm_timer:
            print("Time to Wake up")

def actual_time():
    set_alarm_timer = f"{hour.get()}:{min.get()}:{sec.get()}"

clock = Tk()
clock.title("DataFlair Alarm Clock")
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 in the time input by user:
submit = Button(clock,text = "Set Alarm",fg="red",width = 10,command = actual_time).place(x =110,y=70)

#Execution of the window.


Creating Alarm Clock using Python source code

Related Post


Please enter your comment!
Please enter your name here