custom Tkinter ListBox selectMode

Ron Provost ronpro at cox.net
Fri Jul 1 20:19:20 EDT 2005


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 





More information about the Python-list mailing list