Good day everyone, I'm trying to create comboboxes to input some date, it worked for a while but, I don't know why, it stopped appearing in my frame and I'm not able to fix it. I was also wondering a couple things more: is it possible to have the input of the day with a 0 (like 01, 02 etc) and also to use something like range for the day of the months instead of writing all of them. I cannot do either since I always get errors when I try. Thank for your help!
import tkinter as tk
from tkinter import *
import tkinter.ttk
class MainApplication(tk.Frame):
def __init__(self, parent, *args, **kwargs):
tk.Frame.__init__(self, parent, *args, **kwargs)
self.parent = parent
###BIRTHDAY
birthday_label = tk.Label(self, text="Birthday:", font=('times', 14), anchor='e')
birthday_label.grid(row=3, sticky='e')
month_day = {
'January': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17',
'18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'],
'February': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17',
'18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29'],
'March': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18',
'19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'],
'April': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18',
'19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'],
'May': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18',
'19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'],
'June': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18',
'19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'],
'July': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18',
'19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'],
'August': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17',
'18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'],
'September': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17',
'18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'],
'October': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '15', '16', '17', '18',
'19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'],
'November': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '15', '16', '17', '18',
'19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'],
'December': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17',
'18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31']}
def getUpdateData(self, event):
self.day['values'] = month_day[self.month.get()]
self.day = IntVar(self)
self.day.set(1)
self.day = ttk.Combobox(self)
self.day.grid(row=3, column=1)
self.month = IntVar(self)
self.month.set("January")
self.month = ttk.Combobox(self, values=list(month_day.keys()))
self.month.bind('<<ComboboxSelected>>', self.getUpdateData)
self.month.grid(row=3, column=1, sticky='w')
self.year = IntVar(self)
self.year.set(2000)
self.year = ttk.Combobox(self, values=list(range(1940, 2006)))
self.year.grid(row=3, column=1, sticky='e')
if __name__ == "__main__":
root = tk.Tk()
MainApplication(root).pack(side="top", fill="both", expand=True)
root.mainloop()