Tkinter unbinding

Roger rdcollum at gmail.com
Thu Dec 18 11:24:44 EST 2008


I've done a lot of googling for this topic and I fear that it's not
possible.  I have a widget that is overloaded with several bindings.
I want to be able to unbind one method form the same Event without
destroying all the other bindings to the same event that's associated
to the same widget.

For example:

import Tkinter

def test():
        print 'test'

def test2():
        print 'test2'

root = Tkinter.Tk()
funcid1 = root.bind("<1>", lambda e: test())
funcid2 = root.bind("<1>", lambda e: test2(), add='+')
root.unbind("<1>", funcid2)
root.mainloop()

When run neither <1> binding will exist against the root because the
unbind will unbind all the functions associated with that event.
However, in this example, I only want to unbind test2 not test1.

Any help is greatly appreciated.  Thanks!
Roger.



More information about the Python-list mailing list