Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Allows Misc.unbind to delete only the bound callback
having the given funcid. See the issue above for more.
  • Loading branch information
GiovaLomba authored Jan 6, 2020
commit 95c44046335c2111d81f99f9a0633eb54a9a6fdf
9 changes: 6 additions & 3 deletions Lib/tkinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1385,11 +1385,14 @@ def bind(self, sequence=None, func=None, add=None):
return self._bind(('bind', self._w), sequence, func, add)

def unbind(self, sequence, funcid=None):
"""Unbind for this widget for event SEQUENCE the
function identified with FUNCID."""
self.tk.call('bind', self._w, sequence, '')
"""Unbind for this widget the event SEQUENCE. if
FUNCID is given, delete the command also."""
bound = ''
Comment thread
GiovaLomba marked this conversation as resolved.
Outdated
if funcid:
self.deletecommand(funcid)
Comment thread
terryjreedy marked this conversation as resolved.
Outdated
funcs = self.tk.call('bind', self._w, sequence, None).split('\n')
bound = '\n'.join([f for f in funcs if not f.startswith(f'if {{"[{funcid}')])
Comment thread
GiovaLomba marked this conversation as resolved.
Outdated
self.tk.call('bind', self._w, sequence, bound)

def bind_all(self, sequence=None, func=None, add=None):
"""Bind to all widgets at an event SEQUENCE a call to function FUNC.
Expand Down