Unbinding Tkinter default bindings for Listbox

James Stroud jstroud at mbi.ucla.edu
Mon Jan 12 17:58:58 EST 2009


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



More information about the Python-list mailing list