[issue31485] Tkinter widget.unbind(sequence, funcid) unbind all bindings

Juliette Monsel report at bugs.python.org
Fri Sep 15 10:37:29 EDT 2017


Juliette Monsel added the comment:

I have found a workaround to unbind a single binding (inspired by https://mail.python.org/pipermail/tkinter-discuss/2012-May/003151.html):

def unbind(widget, seq, funcid):
    bindings = {x.split()[1][3:]: x for x in widget.bind(seq).splitlines() if x.strip()}
    try:
        del bindings[funcid]
    except KeyError:
        raise tk.TclError('Binding "%s" not defined.' % funcid)
    widget.bind(seq, '\n'.join(list(bindings.values())))

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31485>
_______________________________________


More information about the Python-bugs-list mailing list