Countdown Clock using Python
The Countdown Clock using Python is a time-based utility application that enables users to set
a specific time duration, after which the program counts down to zero and triggers a notification.
Built primarily with Python’s built-in time module, this project uses basic arithmetic and
looping techniques to convert the user’s input into hours, minutes, and seconds, displaying the
remaining time at one-second intervals. In its simplest form, the timer is implemented via a
command-line interface, where users input the number of seconds for the countdown, and the
program updates the display in real time until the countdown reaches zero. To enhance usability,
the project may also use the Tkinter library to build a graphical interface featuring text boxes,
labels, and start/stop buttons for better user interaction. Once the timer finishes, the application
alerts the user through console messages, GUI pop-ups, or optional sound notifications, making
the tool suitable for cooking, studying, fitness routines, and productivity tasks.
This project demonstrates several key Python programming concepts: functions, loops,
conditional statements, real-time processing, GUI handling, and event-based actions. It can be
extended with additional features such as pause and resume controls, themed UI, multiple timers,
scheduling options, or integration with text-to-speech modules. The Countdown Clock is a
practical beginner-level project that helps students understand how Python interacts with time
and user input. Due to its simplicity and adaptability, the project is ideal for learning project
structuring, modular code design, and real-time program flow, while offering considerable room
for customization and enhancement.
Countdown and Timer Python Code
import time
import threading
import tkinter as tk
from datetime import datetime
from win10toast import ToastNotifier
import winsound
# ------------------ Window Setup ------------------
window = [Link]()
[Link]("650x520")
[Link]("⏳ Countdown Timer")
[Link](bg="#0d0d0d") # Modern black matte theme
# ------------------ Heading -----------------------
title = [Link](window, text="⏳ COUNTDOWN TIMER", font=("Segoe UI
Black", 22, "bold"), bg="#0d0d0d", fg="#00eaff")
[Link](pady=15)
# ------------------ Current Time Display -----------------------
def update_current_time():
now = [Link]()
current_time = [Link]("%H:%M:%S")
time_label.config(text=f"Current Time: {current_time}")
[Link](1000, update_current_time)
time_label = [Link](window, font=("Segoe UI", 16), bg="#0d0d0d",
fg="#FFD700")
time_label.pack()
update_current_time()
# ------------------ Variables -----------------------
check = [Link]()
hour = [Link]()
minute = [Link]()
second = [Link]()
# ------------------ Display Timer -----------------------
display_frame = [Link](window, bg="#0d0d0d")
display_frame.pack(pady=30)
display_label = [Link](display_frame, text="00:00:00", font=("Segoe
UI Black", 38, "bold"), bg="#0d0d0d", fg="#39FF14")
display_label.pack()
# ------------------ Countdown Function -----------------------
def countdown():
h = [Link]()
m = [Link]()
s = [Link]()
total_seconds = h * 3600 + m * 60 + s
while total_seconds >= 0:
mins, secs = divmod(total_seconds, 60)
hrs, mins = divmod(mins, 60)
display_label.config(text=f"{hrs:02d}:{mins:02d}:{secs:02d}")
[Link](1)
total_seconds -= 1
if [Link]():
[Link](700, 1200)
ToastNotifier().show_toast("⏳ Timer Finished", "Countdown has
ended!", duration=5, threaded=True)
# ------------------ Thread function (to prevent freezing) -----------
------------
def start_thread():
th = [Link](target=countdown)
[Link]()
# ------------------ Entry Section -----------------------
[Link](window, text="Set Time (HH : MM : SS)", font=("Segoe UI",
16), bg="#0d0d0d", fg="white").pack(pady=8)
entry_frame = [Link](window, bg="#0d0d0d")
entry_frame.pack()
entry_style = {"width": 5, "font": ("Segoe UI", 18), "justify":
"center"}
[Link](entry_frame, textvariable=hour, **entry_style).grid(row=0,
column=0, padx=6)
[Link](entry_frame, textvariable=minute, **entry_style).grid(row=0,
column=1, padx=6)
[Link](entry_frame, textvariable=second, **entry_style).grid(row=0,
column=2, padx=6)
# Checkbox
[Link](window, text="✓ Enable Sound Alert", variable=check,
font=("Segoe UI", 12), bg="#0d0d0d", fg="white",
selectcolor="#0d0d0d").pack(pady=15)
# ------------------ Start Button -----------------------
start_button = [Link](window, text="▶ Start Countdown",
command=start_thread, width=18, bg="#00eaff", fg="black", font=("Segoe
UI Black", 14), relief="flat", bd=0)
start_button.pack(pady=10)
[Link]()
output: