Tkinter listbox clicking problem
Russell E. Owen
owen at nospam.invalid
Mon Sep 16 13:01:39 EDT 2002
That's odd, the first thing I looked for in Listbox when trying to
answer the original poster's question was the ability to tag items,
since binding events to tagged items would have been a good solution. I
don't think items in a Listbox can be tagged. I fear I'm missing
something, but I'm not sure what. (I imagine one could emulate a Listbox
with a Text widget, tag each line and bind to those tags, but it sounds
like a fair amount of work to get the selection behavior right.)
Fortunately Eric Brunel's suggestion of binding to Button-Release will
do the trick. This is the approach taken by Brian Welch in "Practical
Programming in Tcl and Tk" (which is where I should have looked to start
with). By the time the mouse button is released, you can safely query
the list to ask it for the selection and it will match what the user
sees.
Admittedly the user may be more used to mouse down triggering actions,
but that model just doesn't seem to mesh well with the standard bindings
for Listbox.
-- Russell
>Whoa! There's a far easier solution. Read up on 'bindtags'
>in <URL: http://web.pydoc.org/2.2/Tkinter.html > and elsewhere.
><URL: http://www.cwi.nl/~jacob/textui.py.html > has a small
>example that almost is pertinent.
More information about the Python-list
mailing list