Mini Projects using Python
- YEAR CALENDER GENERATOR.
- STOP WATCH.
This repository contains two Python applications built using Tkinter: a Digital Calendar and a Digital Stopwatch. Both applications provide user-friendly graphical interfaces for time-related functionalities.
A simple calendar application that allows users to view and save calendar layouts for specific months.
- View calendar for any specified year and month
- Save calendar layout to a text file
- Input validation for year and month entries
- Error handling for invalid inputs
The calendar application is structured around these main components:
-
User Interface Components:
- Input fields for year and month
- Display area for calendar
- Buttons for showing and saving the calendar
- Error message dialogs for invalid inputs
-
Core Functions:
display_calendar(year, month)
: Generates and displays the calendar layoutsave_calendar()
: Exports the current calendar view to a text fileshow_calendar()
: Validates input and triggers calendar display
-
Program Flow:
User Input → Input Validation → Calendar Generation → Display/Save
The application uses Python's built-in calendar
module to generate the calendar layout and Tkinter's filedialog
for file saving operations.
A feature-rich stopwatch application with lap timing functionality.
- Start, pause, and reset functionality
- Lap time recording
- 24-hour format display
- List view for recorded lap times
The stopwatch is implemented as a class-based application with the following structure:
-
Class Components:
Stopwatch
class managing the entire application- Time tracking variables (hours, minutes, seconds)
- UI elements (labels, buttons, listbox)
-
Core Methods:
update_clock()
: Updates the time display every secondstart()
: Begins time countingpause()
: Halts time countingreset()
: Resets all values to zerolap()
: Records current time as a lap
-
Program Flow:
Initialize UI → Time Update Loop → User Interactions → Display Updates
The stopwatch uses Tkinter's after
method to create a recurring update cycle every 1000ms (1 second).
- Uses
calendar.TextCalendar()
for generating formatted month layouts - Implements error handling for:
- Non-numeric inputs
- Invalid month values (outside 1-12 range)
- File operations use context managers (
with
statements) for safe file handling - Modal dialogs for user feedback and error messages
- Object-oriented design with a single
Stopwatch
class - Time tracking using internal counters rather than system time
- Automatic rollover handling (seconds → minutes → hours)
- Thread-safe implementation for UI updates
- Persistent display updates using
root.after()
- Python 3.x
- Tkinter (usually comes with Python installation)
- Standard library modules:
calendar
,time
,threading
- Run
python calendar.py
- Enter the desired year and month
- Click "Show Calendar" to view
- Optionally click "Save Calendar" to export
- Run
python current_time.py
- Use the buttons to:
- Start: Begin time counting
- Pause: Stop time counting
- Reset: Clear all times
- Lap: Record current time
Both applications are standalone and can run independently. They showcase different aspects of Python GUI programming using Tkinter and provide practical utilities for time-related tasks.