By default, when moving to another list, the highlight of the current list row is deselected. To avoid this behavior and achieve the preservation of the backlight, you need to set the exportselection parameter to zero for an item of type ListBox :
import tkinter root = tkinter.Tk() leftListBox = tkinter.Listbox(exportselection=0) leftListBox.insert(tkinter.END, "left 1", "left 2", "left 3") leftListBox.pack(side=tkinter.LEFT) middleListBox = tkinter.Listbox() middleListBox.insert(tkinter.END, "middle 1", "middle 2", "middle 3") middleListBox.pack(side=tkinter.LEFT) rightListBox = tkinter.Listbox() rightListBox.insert(tkinter.END, "right 1", "right 2", "right 3") rightListBox.pack(side=tkinter.LEFT) root.mainloop()
At the same time there is one interesting subtlety. This parameter not only causes the list to keep the highlight when moving to another list, but also preserves the highlight of another list from which the transition was made to it. In the example above, the following behavior will be:
- In the
leftListBox highlighted line will always be highlighted. - After selecting the line in the
middleListBox ( rightListBox ) and moving to the leftListBox line in the middleListBox ( rightListBox ) will remain highlighted. - After highlighting a row in the
middleListBox and moving to the rightListBox row highlighting in the middleListBox will be removed.