I'm a beginner in tkinter, so my question might be dumb. Eyes beware.
What I'm trying to do is use a combobox as an "entry" widget. The combobox is created in a function on a Toplevel window, and asks the user to choose a date among the different dates of the box. I have been trying to retrieve the selected value through a bind, but I keep bumping in scope issues when it comes to accessing the combobox ACTIVE value when the button is pressed.
def recupdate(event):
global date = combobox.get(ACTIVE)
def datewindow():
dwindow = tk.Toplevel()
dwindow.title("Date Enquête")
datetxt = Label(dwindow, text="Sélectionnez une date ou créez en une nouvelle")
datetxt.pack(fill='x', padx=5, pady=5)
listedate = read_bdd_date()
btnselect = Button(dwindow, column=0, text="Sélectionner", command=(lbdate.get(lbdate.curselection(ACTIVE())))).pack(dwindow)
combovar = StringVar()
combobox = ttk.Combobox(dwindow, textvariable=combovar)
combobox['values'] = listedate
combobox['state'] = 'readonly'
combobox.pack(fill='x', padx=5, pady=5)
combobox.bind('<<ComboboxSelected>>', recupdate)
NB : the code above is most certainly wrong in some ways. I dont use the stringvar, among other things.
What I try to do here is retrieve the selected value and use it in a return so I can use it somewhere else.
Is is possible ? Should I use a Class to declare this toplevel window ? If yes, how ? Thank you all in advance.