File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff 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" )
You can’t perform that action at this time.
0 commit comments