469,920 Members | 2,403 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,920 developers. It's quick & easy.

custom Tkinter ListBox selectMode

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
Jul 19 '05 #1
1 3451
On Fri, 1 Jul 2005 20:19:20 -0400, Ron Provost <ro****@cox.net> wrote:
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
--
python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17;8(%,5.Z65\'*9--56l7+-'])"
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Nicolas Favre-Félix | last post: by
4 posts views Thread by Patrick L. Nolan | last post: by
reply views Thread by Jeffrey Barish | last post: by
2 posts views Thread by Zhang Le | last post: by
2 posts views Thread by Harlin Seritt | last post: by
3 posts views Thread by Bernard Lebel | last post: by
reply views Thread by Svenn Bjerkem | last post: by
reply views Thread by rahulnag22 | last post: by
reply views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.