I made an array of buttons using for loops for a date picking widget:
current = 1
for c in range(7)
for r in range(5)
b = Button(date_picker_frame, text=str(current), command=lambda: clicked(value_to_pass))
def clicked(value):
self.date = date(self.year, self.month, value)
The text on each of the buttons is the day they represent.
I want them to pass their text as an int
to the clicked
function so it can be saved as a date.
Unfortunately, I can't figure out how to.
I've tried b['text']
, but that always returns the last value of the month because the reference to the button gets lost as the for loop iterates. Similarly, the methods that involve using the reference b
to call something results in the last day of the month being used.
I was thinking of using a method much like an a listboxselect event:
listbox.bind("<<ListboxSelect>>", function_)
But I'm not sure how to. Any solutions?