Skip to content

Commit f164864

Browse files
feat: Add Calendar_Generator_YearWise project (Issue No : #106)
1 parent 5675c6d commit f164864

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# import all functions from the tkinter
2+
from tkinter import *
3+
4+
from tkinter import ttk
5+
6+
#import Calendar module
7+
import calendar
8+
9+
def showCal():
10+
11+
#new calendar window
12+
new_window = Tk()
13+
14+
#setting the background color of GUI application
15+
new_window.config(background = 'white')
16+
17+
#setting the title of the GUI application
18+
new_window.title("Calendar")
19+
20+
#setting the geometry of the GUI application
21+
new_window.geometry('550x600')
22+
23+
# get method returns current text as string
24+
fetch_year = int(year_field.get())
25+
26+
# calendar method of calendar module return
27+
# the calendar of the given year .
28+
cal_content = calendar.calendar(fetch_year)
29+
30+
# Create a label for showing the content of the calender
31+
cal_year = Label(new_window, text = cal_content, font = "Consolas 10 bold")
32+
33+
# grid method is used for placing
34+
# the widgets at respective positions
35+
# in table like structure.
36+
cal_year.grid(row = 5, column = 1, padx = 20)
37+
38+
# start the GUI
39+
new_window.mainloop()
40+
41+
42+
if __name__=='__main__':
43+
44+
#Create the basic gui window
45+
root = Tk()
46+
47+
#setting the background color of GUI application
48+
root.config(background = 'white')
49+
50+
#setting the title of the GUI application
51+
root.title("HOME")
52+
53+
#setting the geometry of the GUI application
54+
root.geometry('500x400')
55+
56+
# Create a CALENDAR : label with specified font and size
57+
cal = Label(root, text = "Welcome to the calendar Application", bg = "Red", font = ("times", 20, 'bold'))
58+
59+
#Create a Year label : a label to ask the user for year
60+
year = Label(root, text = 'Please enter a year',bg = 'Green')
61+
62+
#Create a Year Entry : Entry
63+
year_field = Entry(root)
64+
65+
# Create a Show Calendar Button and attached to showCal function
66+
Show = Button(root, text = "Show Calendar", fg = "Black", bg = "Light Green", command = showCal)
67+
68+
# Create a Exit Button and attached to exit function
69+
Exit = Button(root, text = "Exit", fg = "Black", bg = "Light Green", command = exit)
70+
71+
# grid method is used for placing
72+
# the widgets at respective positions
73+
# in table like structure.
74+
cal.grid(row = 1, column = 1)
75+
76+
year.grid(row = 2, column = 1)
77+
78+
year_field.grid(row = 3, column = 1)
79+
80+
Show.grid(row = 4, column = 1)
81+
82+
Exit.grid(row = 6, column = 1)
83+
84+
# start the GUI
85+
root.mainloop()
86+
87+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Calendar Application
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+
---
11+
## Requirements
12+
```
13+
Python 3.12.6
14+
Tkinter (usually comes with Python installation)
15+
```
16+
## How to Use
17+
- Run the application
18+
- Enter a year in the input field
19+
- Click "Show Calendar" button
20+
-A new window will open displaying the calendar for the entered year
21+
-Use the "Exit" button to close the application
22+
---
23+
24+
## Code Structure
25+
The application consists of:
26+
27+
- Main window with input field
28+
29+
- Calendar display window that opens when showing a calendar
30+
31+
- Simple error handling for year input
32+
---
33+
## How to Run
34+
```
35+
python calendar_app.py
36+
```
37+
---
38+
39+
## Customization
40+
You can easily customize:
41+
- Colors by modifying the bg (background) parameters
42+
- Fonts by changing the font parameters
43+
- Window sizes by adjusting the geometry values
44+
---
45+
## Future Improvements
46+
- Add month-specific calendar views
47+
- Implement date selection functionality
48+
- Add event management features
49+
- Improve UI with modern styling
50+
---
51+
## License
52+
This project is open source and available under the MIT License.

0 commit comments

Comments
 (0)