Skip to content

Commit 4675e46

Browse files
committed
Add Calendar Generator YearWise project (Issue #106)
1 parent 21ae4b7 commit 4675e46

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Calendar Generator YearWise
2+
3+
A simple GUI calendar application built with Python and Tkinter that displays the calendar for any given year.
4+
5+
## Features
6+
- User-friendly interface
7+
- Displays full year calendar in a clean format
8+
- Responsive design
9+
- Easy year input
10+
- Error handling for invalid input
11+
12+
## Usage
13+
1. Run `calendar_app.py`.
14+
2. Enter a year in the input field.
15+
3. Click "Show Calendar" to display the calendar for the entered year.
16+
4. Use the "Exit" button to close the application.
17+
18+
## Requirements
19+
- Python 3.x
20+
- Tkinter (usually included with Python)
21+
22+
## Customization
23+
- Change colors by modifying the `bg` parameters.
24+
- Change fonts by editing the `font` parameters.
25+
- Adjust window sizes via the `geometry` values.
26+
27+
## License
28+
MIT
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""
2+
Calendar Generator YearWise
3+
Issue #106 for king04aman/All-In-One-Python-Projects
4+
"""
5+
import tkinter as tk
6+
from tkinter import messagebox
7+
import calendar
8+
9+
class CalendarApp:
10+
def __init__(self, root):
11+
self.root = root
12+
self.root.title("Yearly Calendar Generator")
13+
self.root.geometry("350x150")
14+
self.root.resizable(False, False)
15+
self.root.configure(bg="#f0f0f0")
16+
17+
tk.Label(root, text="Enter Year:", font=("Arial", 12), bg="#f0f0f0").pack(pady=10)
18+
self.year_entry = tk.Entry(root, font=("Arial", 12), width=15)
19+
self.year_entry.pack(pady=5)
20+
21+
tk.Button(root, text="Show Calendar", command=self.show_calendar, font=("Arial", 12), bg="#4caf50", fg="white").pack(pady=10)
22+
tk.Button(root, text="Exit", command=root.quit, font=("Arial", 12), bg="#f44336", fg="white").pack()
23+
24+
def show_calendar(self):
25+
year = self.year_entry.get()
26+
if not year.isdigit() or int(year) < 1:
27+
messagebox.showerror("Invalid Input", "Please enter a valid positive year.")
28+
return
29+
year = int(year)
30+
cal = calendar.TextCalendar(calendar.SUNDAY)
31+
cal_str = cal.formatyear(year, 2, 1, 1, 3)
32+
self.display_calendar(year, cal_str)
33+
34+
def display_calendar(self, year, cal_str):
35+
cal_win = tk.Toplevel(self.root)
36+
cal_win.title(f"Calendar for {year}")
37+
cal_win.geometry("600x600")
38+
cal_win.configure(bg="#e3f2fd")
39+
text = tk.Text(cal_win, font=("Consolas", 10), bg="#e3f2fd", fg="#212121")
40+
text.insert(tk.END, cal_str)
41+
text.pack(expand=True, fill=tk.BOTH)
42+
tk.Button(cal_win, text="Close", command=cal_win.destroy, font=("Arial", 12), bg="#1976d2", fg="white").pack(pady=10)
43+
44+
if __name__ == "__main__":
45+
root = tk.Tk()
46+
app = CalendarApp(root)
47+
root.mainloop()

0 commit comments

Comments
 (0)