Then, instead of instantiating your failing widget (in my example I use the Canvas) like this m圜anvas = tk.Canvas(.) L for l in func_callbacks if l != funcid] 'bind', self._w, sequence, None).split('\n') ): import tkinter as tkĭeleting-and-changing-a-tkinter-event-binding-in-python
This way, in fact, you do not need to manually change the official source code on your workstation (thus breaking the package management, or reintroducing the problem at the next package update, or having the same issue on another client. Here follow my 2 cents for those who still find themselves stuck with the problem: please, override the unbind() method, DO NOT EDIT IT DIRECTLY. If you experience the problem of not being able to correctly unbind a stacked callback, modifying the official source - if it is still the same! - might be a solution. The answer provided by Bryan generally works well, but as arcra has underlined, it might not. Self.tk.call('bind', self._w, sequence, '\n'.join(new_callbacks))
You need to change it to look somethins like this: def unbind(self, sequence, funcid=None):įunc_callbacks = self.tk.call('bind', self._w, sequence, None).split('\n') Self.tk.call('bind', self._w, sequence, '') """Unbind for this widget for event SEQUENCE the When you find it, you should see something like this: def unbind(self, sequence, funcid=None): You will need to open the source file Tkinter.py and search for the unbind method of the Misc class (if you are using eclipse it's easy to know the file's location and the line in which this function is defined by pressing the F3 key when the cursor is over an.
I can see this is an old question, but for those who, like myself, find this question when facing the same problem, this is what I did to make it work. For me, unbinding a single callback wasn't working, but I found a solution.