Python 3 Tkinter pyfiglet Script to Build Digital Alarm Clock Using WinSound and Datetime Library GUI Desktop App Full Project For Beginners

Python 3 Tkinter pyfiglet Script to Build Digital Alarm Clock Using WinSound and Datetime Library GUI Desktop App Full Project For Beginners

 

Welcome folks today in this blog post we will be building a digital alarm clock in tkinter using winsound and datetime library in tkinter using python. All the full source code of application is shown below.

 

 

Get Started

 

 

In order to get started you need to install the following libraries using the pip command as shown below

 

pip install pyfiglet

 

pip install winsound

 

pip install datetime

 

After installing these libraries make an app.py file and copy paste the following code

 

app.py

 

import tkinter as tk
import winsound
import datetime
from tkinter import *
import pyfiglet


def set_alarm():
    minute, hour, label = min_txt.get(), hour_txt.get(), label_txt.get()
    time_alarm = hour + ':' + minute
    stop = False
    while not stop:
        now = str(datetime.datetime.now().time())

        if now[:5] == str(time_alarm):
            stop = True
            winsound.PlaySound(r'C:\Users\lucaz\Desktop\music\alarm (online-audio-converter.com).wav',
                               winsound.SND_ASYNC)
            banner = pyfiglet.figlet_format(f'{label}')
            print(banner)

            stop_alarm = input("Press \'q\' then ENTER to stop the alarm: ")

            if stop_alarm == 'q':
                winsound.PlaySound(None, winsound.SND_ASYNC)
                window.destroy()


window = tk.Tk()
window.title('test')

label_label = tk.Label(window, text="Alarm Label", ).grid(row=0, column=0)
label_hour = tk.Label(window, text="hour").grid(row=1, column=0)
label_min = tk.Label(window, text="minute").grid(row=2, column=0)

label_txt = tk.Entry(window)
label_txt.grid(row=0, column=1)

hour_txt = tk.Entry(window)
hour_txt.grid(row=1, column=1)

min_txt = tk.Entry(window)
min_txt.grid(row=2, column=1)

button_quit = tk.Button(window, text="Quit", command=window.quit).grid(row=3, column=0)
button_get_info = tk.Button(window, text="set alarm", command=set_alarm).grid(row=3, column=1)

window.mainloop()

 

See also  Python 3 Script to Download Images From a List of Website URLS in Array or Text File Using Imgdl Library Full Project For Beginners

 

Now if you execute the above python script by typing the below command as shown below

 

python app.py

 

Leave a Reply