custom Tkinter ListBox selectMode

R

Ron Provost

Hello,

I've written a simple GUI which contains a listbox to hold some information.
I've found that the click-selection schemes provided by Tkinter are
insufficient for my needs. Essentiall I need to impletement a custom
selectMode. As a first go, I've attempted to implement a click-on-click-off
mode. So for each entry, a click on that entry toggels its selection mode.
A click on any entry does not affect the selection mode of any other entry.

I attempted to implement this by binding

myListBoxWidget.bind( '<ButtonRelease-1>', self.itemClicked )

Where my itemClicked() method determines which item was clicked on then
toggels it's selection state.




So, what's my problem? Well, it doesn't work. The SINGLE selectMode
(default) seems to always take over. I'm tempted to set a simple timer
callback for a short duration which redoes the selection set after the
built-in hander has had a chance to do its thing, but that seems like such a
kludge to me. Any suggestions on how I can implement a custom selectMode?

Thanks for your input.

Ron
 
E

Eric Brunel

Hello,

I've written a simple GUI which contains a listbox to hold some information.
I've found that the click-selection schemes provided by Tkinter are
insufficient for my needs. Essentiall I need to impletement a custom
selectMode. As a first go, I've attempted to implement a click-on-click-off
mode. So for each entry, a click on that entry toggels its selection mode.
A click on any entry does not affect the selection mode of any other entry.

What you describe is exactly the behavior you get when you set selectmode='multiple' on a list box; see:
http://www.tcl.tk/man/tcl8.3/TkCmd/listbox.htm#M57

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top