Apr-08-2021, 12:53 PM
I'm new to Python and coding and after learning the basics I made a "day of the week from date" calculator. It works well.
Now I'm trying to make a gui for it. I'm using tkinter but have fallen at almost the first hurdle. I hope someone can help!?
I've spent two days on this simple task!
I want the user to choose a date, month and year and for each one to be saved as a variable. I'm trying to use Combobox for the selection.
I kind of know whats happening... I'm trying to define q before the user has selected an option from the combobox.
I've added the chosen_day label at the end just to check that q is set. I've tried everything (almost)! Maybe I shouldn't be using a function?
Here is an example... I want the user to choose a date between 1st and 31st and for it to be saved as variable "q".
Thanks for any help
Now I'm trying to make a gui for it. I'm using tkinter but have fallen at almost the first hurdle. I hope someone can help!?
I've spent two days on this simple task!
I want the user to choose a date, month and year and for each one to be saved as a variable. I'm trying to use Combobox for the selection.
I kind of know whats happening... I'm trying to define q before the user has selected an option from the combobox.
I've added the chosen_day label at the end just to check that q is set. I've tried everything (almost)! Maybe I shouldn't be using a function?
Here is an example... I want the user to choose a date between 1st and 31st and for it to be saved as variable "q".
Thanks for any help
def selected_day(event): q = combo_day.get() return q combo_day = Combobox(frame) combo_day['values'] = list (range(1,32)) combo_day.set("Choose a day") combo_day.grid(row=0, column=0) combo_day.bind("<<ComboboxSelected>>", selected_day) q = selected_day() chosen_day = Label(frame, text=q).grid(row=1, column=0) root.mainloop()