A feature-rich GUI-based countdown timer application with start, pause, resume, reset, and close functionality. The timer displays time in HH:MM:SS format and changes colors as time runs out, providing visual feedback to the user.
- Clean and modern dark-themed GUI
- Input time in seconds
- Large, easy-to-read countdown display (HH:MM:SS format)
- Start button to begin countdown
- Pause/Resume button to pause and resume timer
- Reset button to clear and restart
- Close button with confirmation dialog
- Color-changing display (green → orange → red as time decreases)
- Visual and audio alert when timer finishes
- Non-blocking timer using Tkinter's
after()method - Input validation and error handling
- Language: Python
- Libraries:
tkinter(standard library - GUI)tk==0.1.0(wrapper package)
- Complexity: Beginner-Intermediate
# Install dependencies
pip install -r requirements.txt
# Run the program
python main.py-
Start the application:
python main.py
-
Enter time:
- Click on the input field
- Enter time in seconds (e.g., 60 for 1 minute, 300 for 5 minutes)
- Press Enter or click "Start"
-
Control the timer:
- Start: Begin countdown
- Pause: Pause the countdown
- Resume: Continue from where you paused
- Reset: Stop and clear the timer
- Close: Exit the application
-
Timer completion:
- Display shows 00:00:00 in red
- Popup message appears: "⏰ Countdown finished!"
The application uses OOP design with CountDownTimer class inheriting from Frame:
class CountDownTimer(Frame):
def __init__(self, master=None)
def create_widgets()
def enter(event)
def start_time()
def pause_time()
def reset_time()
def close_app()
def countdown(time_in_seconds, start=False)_alarm_id: Stores the ID of scheduledafter()call_paused: Boolean flag for pause state_start_time: Initial time in seconds
- User enters time in seconds
start_time()validates input and starts countdowncountdown()recursively calls itself every 1000ms (1 second)- Each iteration:
- Checks if paused
- Decrements time if not paused
- Updates display
- Changes color based on remaining time
- Schedules next call using
master.after(1000, ...)
- When time reaches 0:
- Shows completion message
- Resets button states
Uses master.after() for event-driven countdown:
- No threading needed
- UI remains responsive
- Can pause/resume/reset at any time
- Green (#1abc9c): Normal countdown (> 30 seconds)
- Orange (#f39c12): Warning (11-30 seconds)
- Red (#e74c3c): Critical (≤ 10 seconds) and finished
┌─────────────────────────────────────┐
│ ⏱️ CountDown Timer │
│ │
│ [Enter Time in seconds] │
│ │
│ [Start] [Pause] │
│ [Reset] [Close] │
│ │
│ 00:00:00 │
│ │
└─────────────────────────────────────┘
Creates all GUI components:
- Title label
- Input entry field
- Control buttons (Start, Pause, Reset, Close)
- Countdown display label
- Validates user input
- Converts to integer
- Checks for positive value
- Initializes countdown
- Updates button states
- Toggles
_pausedflag - Changes button text (Pause ↔ Resume)
- Changes button color
- Cancels scheduled
after()call - Resets all variables
- Clears display
- Restores initial button states
- Recursive function called every second
- Updates display with formatted time
- Changes color based on remaining time
- Handles pause state
- Shows completion message when done
- Checks for empty input
- Validates numeric input
- Ensures positive values
- Shows appropriate error messages
Input: 300
Display: 00:05:00 → 00:04:59 → ... → 00:00:01 → 00:00:00
Input: 3600
Display: 01:00:00 → 00:59:59 → ... → 00:00:01 → 00:00:00
- Enter: Start timer (when input field is focused)
- Escape: Close confirmation dialog
self.master.geometry("width x height")# Normal color
self.label.config(fg="#your_color")
# Background
self.master.config(bg="#your_color")# Update every 100ms instead of 1000ms
self._alarm_id = self.master.after(100, self.countdown, time_in_seconds, False)def countdown(self, time_in_seconds, start=False):
if time_in_seconds == 0:
import winsound
winsound.Beep(1000, 1000) # Frequency, Duration- Tkinter GUI development
- OOP design with inheritance
- Event-driven programming
- Non-blocking timers using
after() - State management (pause/resume)
- Input validation
- Time formatting and calculations
- User experience design (color feedback)
- Preset timer buttons (1 min, 5 min, 10 min, etc.)
- Multiple simultaneous timers
- Timer history
- Custom alarm sounds
- Save/load timer presets
- System tray integration
- Keyboard shortcuts for all actions
- Progress bar visualization
- Dark/light theme toggle
- Timer templates (Pomodoro, workout, cooking, etc.)
- Precision limited to 1 second
- No persistence (resets on close)
- Single timer at a time
- No background operation when minimized
- Ensure you've entered a valid number
- Check that the number is positive
- Make sure you clicked "Start" or pressed Enter
- Check if window is minimized
- Ensure window is not behind other windows
- Wait for current operation to complete
- Try resetting the timer
This project is open source and available for educational purposes.