Jul-01-2020, 08:13 PM
This is my code right now:
from datetime import datetime from tkinter.ttk import * from tkinter import * from openpyxl import * class Application(Tk): def __init__(self, *args, **kwargs): Tk.__init__(self, *args, **kwargs) d29 = list(range(1, 30)) d30 = list(range(1, 31)) d31 = list(range(1, 32)) self.months = dict( January=d31, February=d29, March=d31, April=d30, May=d31, June=d30, July=d31, August=d31, September=d30, October=d31, November=d30, December=d31) self.lbl_birth = Label(self, text="Birthday:", font=('times', 14)) self.lbl_birth.grid(row=1, column=1) self.cb_day = Combobox(self, values=self.months["January"]) self.cb_day.grid(row=1, column=2) self.cb_day.set("1") self.cb_month = Combobox(self, values=[*self.months]) self.cb_month.bind('<<ComboboxSelected>>', self.update) self.cb_month.grid(row=1, column=3) self.cb_month.set("January") self.cb_year = Combobox(self, values=list(range(1996, 2006))) self.cb_year.grid(row=1, column=4) self.cb_year.set("2000") day, month, year = self.cb_day.get(), self.cb_month.get(), self.cb_year.get() mydate = datetime.strptime(f'{day} {month} {year}', '%d %B %Y') today = datetime.now() years = today.year - mydate.year def update(self, event): self.cb_day["values"] = self.months[self.cb_month.get()] self.cb_day.set("1") if __name__ == "__main__": app = Application() app.title('My Birthday App') app.mainloop()Thank you