Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Age Calculator

Description

A beautiful GUI application that calculates your exact age from your birth date. Get detailed breakdowns including years, months, days, weeks, hours, and even days until your next birthday! Built with Python and Tkinter with a modern, user-friendly interface.

Features

  • 🎂 Beautiful GUI with modern design
  • 📅 Date picker for easy birth date selection
  • 📊 Exact age calculation (years, months, days)
  • 📈 Detailed breakdown (total months, weeks, days, hours)
  • 🎉 Next birthday countdown
  • Input validation and error handling
  • 🎨 Clean, intuitive interface

Stack

  • Language: Pure Python
  • Libraries:
    • tkinter (standard library) - GUI
    • tkcalendar==1.6.1 - Date picker widget
    • datetime (standard library) - Date calculations
  • Complexity: Beginner

Installation

# Install dependencies
pip install -r requirements.txt

# Run the application
python main.py

Usage

  1. Launch the app: Run python main.py
  2. Enter your name in the text field
  3. Select your birth date using the date picker
  4. Click "Calculate Age" button
  5. View your results with detailed breakdown!

Screenshot Preview

┌─────────────────────────────────────┐
│      🎂 Age Calculator              │
├─────────────────────────────────────┤
│  Name: [Your Name]                  │
│  Birth Date: [DD/MM/YYYY] 📅        │
│         [🎯 Calculate Age]          │
├─────────────────────────────────────┤
│  📊 EXACT AGE:                      │
│     24 years, 3 months, 15 days     │
│                                     │
│  📈 DETAILED BREAKDOWN:             │
│     • Total Months: 291 months      │
│     • Total Weeks: 1,268 weeks      │
│     • Total Days: 8,876 days        │
│     • Total Hours: 213,024 hours    │
│                                     │
│  🎉 NEXT BIRTHDAY:                  │
│     25 January 2026 (102 days!)     │
└─────────────────────────────────────┘

How It Works

  1. Input: User enters name and selects birth date via date picker
  2. Validation:
    • Checks name is not empty
    • Ensures birth date is not in the future
    • Validates date format
  3. Calculation:
    • Gets today's date using date.today()
    • Calculates exact age by comparing birth date with today
    • Adjusts for negative days/months (handles month boundaries)
    • Calculates total days using (today - birth_date).days
    • Computes weeks, hours from total days
    • Determines next birthday and countdown
  4. Display: Shows formatted results in GUI with emojis and separators

Key Features Explained

Exact Age Calculation

  • Properly handles month boundaries (e.g., Jan 31 → Feb 28)
  • Accounts for leap years in February
  • Adjusts for negative days/months correctly

Date Picker Widget

  • Calendar popup for easy date selection
  • Restricts selection to past dates only (maxdate=date.today())
  • Format: DD/MM/YYYY

Next Birthday Countdown

  • Calculates next occurrence of birth date
  • Handles current year vs next year logic
  • Shows exact days remaining

Error Handling

  • ✅ Name validation (not empty)
  • ✅ Birth date validation (not in future)
  • ✅ Date format validation
  • ✅ Exception handling with user-friendly messages
  • ✅ Graceful error dialogs

Learning Outcomes

  • Building GUI applications with Tkinter
  • Working with datetime module for date calculations
  • Using third-party widgets (tkcalendar)
  • Date arithmetic and edge case handling
  • Input validation in GUI applications
  • Modern UI/UX design principles
  • Object-oriented programming with classes

Improvements Over Console Version

Visual interface - No command line needed
Date picker - No manual date entry errors
More metrics - Weeks, hours, next birthday
Better UX - Instant results, no re-running
Professional look - Modern design with colors

License

This project is open source and available for educational purposes.