Skip to content

Commit f4da83f

Browse files
author
Chloe White
committed
calendar display function
1 parent 95d04aa commit f4da83f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

calendar_display/calendar_app.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,24 @@ def main():
1212
year_entry.pack(pady=5)
1313

1414
def show_calendar():
15-
# Placeholder function for showing calendar
16-
print("Show calendar function placeholder")
15+
year = year_entry.get()
16+
if not year.isdigit():
17+
messagebox.showerror("Invalid Input", "Please enter a valid year")
18+
return
19+
display_calendar(year)
1720

1821
tk.Button(root, text="Show Calendar", command=show_calendar).pack(pady=5)
1922
tk.Button(root, text="Exit", command=root.destroy).pack(pady=5)
2023

2124
root.mainloop()
2225

23-
if __name__ == "__main__":
24-
main()
26+
def display_calendar(year):
27+
try:
28+
year = int(year)
29+
if year < 1:
30+
raise ValueError
31+
cal = calendar.TextCalendar()
32+
cal_str = cal.formatyear(year)
33+
messagebox.showinfo(f"Calendar for {year}", cal_str)
34+
except ValueError:
35+
messagebox.showerror("Invalid Input", "Please enter a valid positive year")

0 commit comments

Comments
 (0)