Answer the question
In order to leave comments, you need to log in
Dropdown menu, listbox and python - how to be?
Is it possible to create a drop-down menu using the standard tkinter library (yes, at least this: ) and how to "get" the selected option from it? And if not, how can I "get" the selected item from the Listbox? (.get() throws an error)
PS: if it doesn't make it difficult - with examples, please
Answer the question
In order to leave comments, you need to log in
Create a list, bind a function to it and perform operations in it. Example:
root = Tk()
root.wm_geometry("%dx%d+%d+%d" % (400, 150, 20, 40))
listbox_items = ['Раз', 'Два', 'Три']
def select_item(event):
value = (listbox.get(listbox.curselection()))
print(value)
listbox = Listbox(root, width=40, height=5, font=('times', 13))
listbox.bind('<<ListboxSelect>>', select_item)
listbox.place(x=15, y=15)
for item in listbox_items:
listbox.insert(END, item)
root.mainloop()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question