Tkinter Multilistbox Lists Are Independent Of Each Other
enter image description hereI want to create multiple lists with this code and let the lists I create work with each other. When I make mlb.get (ACTIVE), the value in the list is c
Solution 1:
Question: Multiple
Listbox
in classMultiListbox
should behave in sync by clicked in oneListbox
.
Change/add the following:
- Bind to event
'<<ListboxSelect>>'
classMultiListbox(Frame):def__init__(self, master, lists): ... for l, w inlists: ... lb.bind('<<ListboxSelect>>', self.on_select)
Change your global
def info():
to a class methoddef on_select(...
def on_select(self, event): w = event.widget curselection = w.curselection() if curselection: self.selection_clear(0, self.size()) self.selection_set(curselection) mlb_get = mlb.get(curselection) yazi.config(text=mlb_get) print(mlb_get)
- In
__main__
remove the statement:info()
# info()
Post a Comment for "Tkinter Multilistbox Lists Are Independent Of Each Other"