Alarm Clock Using Python With Source Code

Alarm Clock Using Python With Source Code

The Alarm Clock Using Python is a project that written in python programming language, The objective of this Python Alarm Clock Tutorial is to implement an Python Alarm Clock GUI.

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

This article 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 in your computer.

Alarm Clock Using Python With Sourc...
Alarm Clock Using Python With Source Code Free Download 2020

By the way if you are new to python programming and you don’t know what would be the the Python IDE to use, I have here a list of Best Python IDE for Windows, Linux, Mac OS that will suit for you. I also have here How to Download and Install Latest Version of Python on Windows.

Steps on how to create a Alarm Clock Using Python.

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.

The Code Given Below Is For Importing Modules.

from tkinter import *
import datetime
import time
import winsound

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

The Code Given Below Is For The Module Actual Time.

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

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

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

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

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

The Code Given Below Is For The GUI

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.

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 : 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
Alarm Clock Using Python – Project Information

Downloadable Source Code

I have here the list of Best Python Project 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 project using the current date and time. Apart from this, they provide a user interface to set the alarm according to the requirement in 24-hour format.

Inquiries

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

Leave a Comment