Reputation: 423
When a tkinter form includes a listbox and other widgets, clicking on the other widgets (especially if the mouse is dragged) causes the listbox to lose its selection -- meaning that the element(s) that was/were selected/highlighted in the lisbox become unselected.
I've seen this problem discussed in one or two places on the Net, with this solution proposed: set the listbox exportselection
value to False
:
lb = Listbox(leftPane, width=24, height=4, selectmode=EXTENDED)
lb.exportselection = False
But that doesn't work at all in my apps. (Tried on Tkinter 8.5 and Tkinter 8.6.1, Python 3.3, Python 3.4... on a variety of Linux distributions. The problem is remarkably constant, regardless of the app in which the listobox is, or the environment in which it's deployed.)
Ideas?
Upvotes: 4
Views: 4065
Reputation: 71
And if you happen to be using the python megawidgets module version of the listbox, (Pmw.ScrolledListBox(...)), doing yearsLB.component('listbox').configure(exportselection=False) worked for me.
Upvotes: 0
Reputation: 385890
You are doing it wrong. You need to use the config (or configure) method:
lb.configure(exportselection=False)
Upvotes: 14