Skip to content

Commit fd76750

Browse files
authored
Merge pull request Shahrayar123#76 from filza2112/another
Created a Tkinter Alarm clock
2 parents 09e2307 + 858d92a commit fd76750

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

Tkinter Clock/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<h1> Tkinter Alarm Clock </h1>
2+
<h3>Introduction</h3>
3+
<p>Tkinter Alarm Clock is a simple desktop application built using the Tkinter library in Python. It allows users to set alarms and receive notifications when the alarm time is reached.</p>
4+
5+
<h3>Requirements</h3>
6+
7+
<p>To run the Tkinter Alarm Clock application, ensure that you have the following installed:</p>
8+
9+
<ul style="list-style-type:circle">
10+
<li>Python (version 3.x)</li>
11+
<li>Tkinter library</li>
12+
<li>winsound library (for sound playback on Windows)</li>
13+
</ul>
14+
15+
<h3>Usage</h3>
16+
17+
<p>Once the Tkinter Alarm Clock application is running, follow these steps to set an alarm:</p>
18+
<ul style= "list-style-type:circle">
19+
20+
<li>Enter the desired alarm time in the format HH:MM:SS (24-hour format) in the corresponding text fields for hours, minutes, and seconds.</li><
21+
22+
<li>Click the "Set Your Alarm" button to set the alarm.</li>
23+
24+
<li>The application will continuously check the current time against the set alarm time. When the alarm time is reached, it will play a sound (if available) and display the current time in the terminal.</li>
25+
26+
<li>To stop the alarm, close the application window.</li>
27+
28+
</ul>
29+
30+
<h3>Conclusion</h3>
31+
32+
<p>The Tkinter Alarm Clock application provides a simple and convenient way to set alarms and receive notifications. You can use it as is or customize it to suit your specific requirements. Enjoy using the Tkinter Alarm Clock!</p>
33+
34+
35+

Tkinter Clock/main.py.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from tkinter import *
2+
import datetime
3+
import time
4+
import winsound
5+
6+
def Alarm(set_alarm_timer):
7+
while True:
8+
time.sleep(1)
9+
actual_time = datetime.datetime.now()
10+
cur_time = actual_time.strftime("%H:%M:%S")
11+
cur_date = actual_time.strftime("%d/%m/%Y")
12+
msg="Current Time: "+str(cur_time)
13+
if cur_time == set_alarm_timer:
14+
winsound.PlaySound("Music.wav",winsound.SND_ASYNC)
15+
break
16+
def get_alarm_time():
17+
alarm_set_time = f"{hour.get()}:{min.get()}:{sec.get()}"
18+
Alarm(alarm_set_time)
19+
window = Tk()
20+
window.title("Alarm Clock")
21+
window.geometry("400x160")
22+
window.config(bg="#922B21")
23+
window.resizable(width=False,height=False)
24+
time_format=Label(window, text= "Remember to set time in 24 hour format!", fg="white",bg="#922B21",font=("Arial",15)).place(x=20,y=120)
25+
addTime = Label(window,text = "Hour Min Sec",font=60,fg="white",bg="black").place(x = 210)
26+
setYourAlarm = Label(window,text = "Set Time for Alarm: ",fg="white",bg="#922B21",relief = "solid",font=("Helevetica",15,"bold")).place(x=10, y=40)
27+
hour = StringVar()
28+
min = StringVar()
29+
sec = StringVar()
30+
hourTime= Entry(window,textvariable = hour,bg = "#48C9B0",width = 4,font=(20)).place(x=210,y=40)
31+
minTime= Entry(window,textvariable = min,bg = "#48C9B0",width = 4,font=(20)).place(x=270,y=40)
32+
secTime = Entry(window,textvariable = sec,bg = "#48C9B0",width = 4,font=(20)).place(x=330,y=40)
33+
submit = Button(window,text = "Set Your Alarm",fg="Black",bg="#D4AC0D",width = 15,command = get_alarm_time,font=(20)).place(x =100,y=80)
34+
window.mainloop()

0 commit comments

Comments
 (0)