Alarm Clock Using Python With Source Code

The Alarm Clock Using Python consists of very useful libraries such as datetime and tkinter which help us to build projects using the current date and time.

Apart from this, they provide a user interface to set the alarm according to the requirement in a 24-hour format.

Alarm Clock Using Python: Project Information

Project Name:Alarm Clock Using Python
Language/s Used:Python (GUI) Based
Python version (Recommended):2.x or 3.x
Database:None
Type:Python App
Developer:IT SOURCECODE
Updates:0

This Python Alarm Clock also includes a downloadable Python Alarm Clock Code for free. To start creating this simple project Alarm Clock Using Python, make sure that you have Pycharm IDE installed on your computer.

By the way, if you are new to Python programming and don’t know what Python IDE to use, I have here a list of the Best Python IDE for Windows, Linux, and Mac OS that will suit you.

I also have here How to Download and Install the Latest Version of Python on Windows.

How To Make a Simple Alarm Clock in Python: A Step-by-step Guide

Time needed: 5 minutes

These are the steps on how to create an Alarm Clock Using Python With Source Code

  • Step 1: Create a project name.

    First, open Pycharm IDE and then create a “project name.” After creating a project name click the “create” button.
    Alarm Clock Using Python Project Name

  • Step 2: Create a python file.

    Second, after creating a project name, “right click” your project name and then click “new” After that click the “python file.“Alarm Clock Using Python Python File

  • Step 3: Name your python file.

    Third, after creating a Python file, Name your Python file after that click “enter“.
    Alarm Clock Using Python File Name

  • Step 4: The actual code.

    You are free to copy the code given below and download the full source code below.

Code Explanation

1. The Code Given Below Is For Importing Modules

Code:

from tkinter import *
import datetime
import time
import winsound

Explanation:

In the given code which is importing all modules that are being called in executing the program.

2. The Code Given Below Is For The Module Actual Time

Code:

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

Explanation:

In this module which is the actual or the current time that is being called when setting the alarm.

3. The Code Given Below Is For The Module Of Setting The Alarm

Code:

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.mp3",winsound.SND_ASYNC)
            break

Explanation:

In this module which is the setting of alarm that is being executed.

4. The Code Given Below Is For The GUI

Code:

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.

Explanation:

In this module which is the design or the graphical user interface or (GUI) of this project.

Complete Source Code


#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.mp3",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.

Output:

Alarm-Clock-Using-Python-Output
Alarm-Clock-Output

Downloadable Source Code

I have here the list of Best Python Projects with Source code free to download for free, I hope this can help you a lot.

Objective

The objective of this project Alarm Clock Using Python is to implement an alarm clock using Python.

Python consists of very useful libraries such as datetime and tkinter which help us to build projects using the current date and time. Apart from this, they provide a user interface to set the alarm according to the requirement in a 24-hour format.

Inquiries

If you have any questions or suggestions about Alarm Clock Using Python, please feel free to leave a comment below.

Frequently Asked Questions

How does this Python clock or timer project work?

Uses Tkinter Label + after() loop to update display every 1000ms. time.strftime() formats current time. Alarm version stores target time + plays sound via pygame.mixer or winsound when reached.

What Python version and libraries does this project require?

Most projects in this batch use Python 3.10, 3.11, or 3.12 (avoid 3.13 until library wheels catch up). Standard libs: tkinter (built-in), sqlite3 (built-in). External: pip install pillow opencv-python pygame mysql-connector-python reportlab requests beautifulsoup4. Check the requirements.txt file (if included) for exact versions.

How do I set up the database for this Python project?

For SQLite (most common, no setup needed): the .db file auto-creates on first run. For MySQL: install MySQL Server + MySQL Workbench, create an empty database, import the included .sql file, edit the connection string in db.py (or db_connect.py) with your host, user, password, database name.

Can I use this Python project for a BSIT capstone or thesis?

Yes. Python is rising fast in Philippine BSIT panels. Extend it: add user roles via auth module, dashboards (matplotlib charts), PDF reports (reportlab), email notifications (smtplib), real domain extension (analytics, audit log, multi-branch support). Pair with Chapter 1-5 documentation matching your panel’s rubric.

Why am I getting ‘ModuleNotFoundError’ or ‘No module named X’?

Three common Python issues: (1) Module not installed: pip install (use pip3 on macOS/Linux). (2) Wrong virtualenv: activate the project’s venv before running (python -m venv venv then venv\Scripts\activate on Windows or source venv/bin/activate on Linux/macOS). (3) Python 2 vs Python 3 mismatch: ensure you run python3 main.py not python main.py if both are installed.

Where can I find more Python projects with source code?

Browse the Python Projects hub for the full library. For computer vision specifically see OpenCV Projects (46 vision systems). For ML / AI capstones see Machine Learning Projects. For BSIT capstone idea lists see 150 Best Capstone Project Ideas.

Angel Jude Suarez

Full-Stack Developer at PIES IT Solution

Focuses on Python development, machine learning, and AI integration. Has built production AI systems including OpenAI Whisper integration for medical transcription and GPT-4o-powered diagnosis assistance. Strong background in pandas, scikit-learn, and TensorFlow.

Expertise: Python · PHP · Java · VB.NET · ASP.NET · Machine Learning · AI Integration · OpenCV · Django · CodeIgniter  · View all posts by Angel Jude Suarez →

Leave a Comment