Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Alarm Bot

Description

A simple alarm/reminder application with a graphical user interface (GUI). Set an alarm time using dropdown menus, and the application will alert you when the time arrives with both a visual popup and an audio alarm.

Features

  • Clean and modern GUI interface
  • Easy-to-use dropdown menus for time selection (hours, minutes, seconds)
  • Visual alarm notification with popup message
  • Audio alarm (platform-specific beeps)
  • Non-blocking alarm using threading
  • Status indicator showing alarm state
  • Cross-platform support (Windows, macOS, Linux)

Stack

  • Language: Python
  • Libraries:
    • tkinter (standard library - GUI)
    • datetime (standard library)
    • time (standard library)
    • threading (standard library)
    • winsound (standard library - Windows only)
    • tk==0.1.0 (wrapper package)
  • Complexity: Beginner

Installation

# Install dependencies
pip install -r requirements.txt

# Run the program
python main.py

Usage

  1. Run the application:

    python main.py
  2. Select alarm time:

    • Choose hour (00-23)
    • Choose minute (00-59)
    • Choose second (00-59)
  3. Click "Set Alarm" button

  4. Wait for the alarm to trigger at the specified time

  5. When the alarm goes off:

    • A popup message will appear
    • An audio alert will play (platform-specific)

How It Works

GUI Components

  • Window: 400x250 pixels with modern dark theme
  • Title: "⏰ Alarm Clock" with red styling
  • Time Selection: Three dropdown menus (hours, minutes, seconds)
  • Set Alarm Button: Green button to activate alarm
  • Status Label: Shows current alarm status

Threading

  • Uses threading.Thread to run alarm check in background
  • Prevents UI from freezing while waiting for alarm
  • Daemon thread automatically stops when main program exits

Alarm Logic

  1. User selects alarm time using dropdown widgets
  2. Click "Set Alarm" button to start alarm thread
  3. Thread continuously checks current time vs alarm time every 1 second
  4. When times match:
    • Display popup message
    • Play audio alert
    • Reset alarm state

Audio Alerts

  • Windows: Uses winsound.Beep() for system beeps
  • macOS: Plays system alarm sound
  • Linux: Uses paplay for audio playback

Key Functions

  • __init__(root): Initialize GUI and variables
  • create_widgets(): Build all GUI components
  • start_alarm_thread(): Start alarm in separate thread
  • alarm(): Main loop that checks time every second
  • trigger_alarm(): Execute when alarm time is reached
  • play_alarm_sound(): Platform-specific audio playback

GUI Layout

┌─────────────────────────────────┐
│      ⏰ Alarm Clock              │
│                                  │
│      Set Alarm Time              │
│                                  │
│    [HH] : [MM] : [SS]           │
│                                  │
│      [ Set Alarm ]               │
│                                  │
│      Status: No alarm set        │
└─────────────────────────────────┘

Platform Support

Windows

  • Full support with winsound module
  • System beep sounds for alarm

macOS

  • Uses system alarm sound
  • Requires /System/Library/Sounds/Alarm.aiff

Linux

  • Uses freedesktop sound theme
  • Requires paplay audio player

Error Handling

  • Prevents multiple alarms from running simultaneously
  • Graceful handling of missing audio files
  • Thread-safe alarm state management
  • Disabled button while alarm is active

Customization

Change Colors

# In create_widgets()
self.root.config(bg="#your_color")  # Background
title_label.config(fg="#your_color")  # Text color

Change Window Size

self.root.geometry("width x height")

Add Custom Sound

Replace the play_alarm_sound() function to use your own audio file:

import pygame
pygame.mixer.init()
pygame.mixer.music.load("your_sound.wav")
pygame.mixer.music.play()

Learning Outcomes

  • Tkinter GUI development
  • Threading for non-blocking operations
  • Date/time manipulation
  • Event-driven programming
  • Platform-specific code handling
  • StringVar and OptionMenu widgets

Future Enhancements

  • Multiple alarms support
  • Recurring alarms (daily, weekly)
  • Custom alarm sounds
  • Snooze functionality
  • Alarm history
  • Dark/light theme toggle
  • System tray integration
  • Alarm labels/descriptions

Known Limitations

  • Alarm only triggers if application is running
  • Audio playback depends on system configuration
  • Time must match exactly (second precision)
  • No alarm persistence (resets on app close)

License

This project is open source and available for educational purposes.