Skip to content Skip to sidebar Skip to footer

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 class MultiListbox should behave in sync by clicked in one Listbox.

Change/add the following:

  1. Bind to event '<<ListboxSelect>>'
    classMultiListbox(Frame):def__init__(self, master, lists):
            ...
            for l, w inlists:
                ...
                lb.bind('<<ListboxSelect>>', self.on_select)
    
  2. Change your global def info(): to a class method def 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)
    
  3. In __main__ remove the statement: info()
    # info()
    

Post a Comment for "Tkinter Multilistbox Lists Are Independent Of Each Other"