Tkinter binding question
Frederic Rentsch
anthra.norell at bluewin.ch
Mon Jun 18 14:21:02 EDT 2012
Hi All,
For most of an afternoon I've had that stuck-in-a-dead-end feeling
probing to no avail all permutations formulating bindings, trying to
make sense of manuals and tutorials. Here are my bindings:
label_frame.bind ('<Enter>', self.color_selected)
label_frame.bind ('<Leave>', self.color_selectable)
label_frame.bind ('<Button-1><ButtonRelease-1>', self.pick_record)
label_frame.bind ('<Button-3><ButtonRelease-3>', self.info_profile)
<Enter> and <Leave> work fine. But when I try to select an entered item,
the moment I push the left or the right button, color_selectable ()
and color_selected () are called again in rapid succession. The same
effect happens even when I push the middle mouse button which is
rather weird, because it has no binding. The behavior suggests that
no event can occur on an entered widget before it is left again and
if an event other that <Leave> comes in, the <Leave> callback gets
called automatically. That can't be right, though. It isn't possible
to click an item without entering it.
I put traces in all of the four callbacks. So I know what gets
called an what doesn't. Traces are:
On <Enter>:
hit list.color_selected ()
On <Leave>:
hit list.color_selectable ()
Fine so far.
<Enter>:
hit list.color_selected () # Still fine
<Button-1> or <Button-2> or <Button-3>:
hit list.color_selectable () # Not so fine!
hit list.color_selected ()
<ButtonRelease-1> (or -2 or -3)
(nothing)
Thanks for any suggestion
Frederic
OS: Ubuntu 10.04 LTS
Python: sys.version: 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3]
Tkinter: VERSION 73770 (help (Tkinter), last line)
More information about the Python-list
mailing list