Unbinding Tkinter default bindings for Listbox

Roger rdcollum at gmail.com
Tue Jan 13 02:13:04 CET 2009

On Jan 12, 5:58 pm, James Stroud <jstr... at mbi.ucla.edu> wrote:
> James Stroud wrote:
> > tk.tk.call('bind', str(lb), '<Leave>', "break")
> Which is equivalent to
> lb.bind('<Leave>', "break")
> But I checked and overriding the default behavior of Listbox does not
> work (tk.tk.call('bind', "Listbox", '<Leave>', "break")).
> So I would subclass Listbox and do the bindings in the __init__:
> class MyListbox(Listbox):
>    def __init__(self, *args, **kwargs):
>      Listbox.__init__(self, *args, **kwargs)
>      self.bind('<Leave>', "break")
> James

You sir are awesome.  Thank you so much.  I've so far been really good
at troubleshooting Tkinter, the library has really melded with my
thinking naturally since I started using Python on a regular basis a
year ago.  I had mixed feelings about asking for help on this because
I wanted so badly to figure it out myself but I became so exasperated
especially after combing through the TCL source to no affect.  Now
that you've given me the correct solution it seems like the Leave
event should have been a natural binding for me to break in all my

Ah well, it's a lesson I won't forget thanks to you.  Thanks so much
again, you're help is invaluable.  =D


More information about the Python-list mailing list