I am creating a tkinter program which takes in the policy number and date of birth of a customer. I wanted to create dropbox menus each for day, month, and year for obtaining the date of birth. So here's what I did:
years=[1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000]
months=['January','February','March','April','May','June','July','August','September','October','November','December']
days=[01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
clicked1=IntVar()
clicked2=StringVar()
clicked3=IntVar()
dof_year=OptionMenu(root,clicked1,*years)
dof_month=OptionMenu(root,clicked2,*months)
dof_day=OptionMenu(root,clicked3,*days)
But then I realized a serious problem. Months have 30 and 31 days alternatively and February has 28 or 29 days.
I could prompt the user to first enter the year and month and click a button, then by using if-else statements, determine how many days I am supposed to give in the dropbox menu, and then show the days menu.
But that will look really unprofessional. So is there a way that when the user inputs the year and month, the "days" list updates dynamically without pressing any button?
Like for example, when I choose the year 1980 and the month "March", the 'days' menu instantly updates itself, so that when i click it, it shows me the exact number of days in that month.
Thanks!