Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 commits
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
17 changes: 13 additions & 4 deletions Lib/tkinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1385,11 +1385,20 @@ 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, '')
if funcid:
"""Unbind for this widget the event SEQUENCE.

If FUNCID is given, only unbind the function identified with FUNCID.
and also delete that command.
"""
if funcid is None:
self.tk.call('bind', self._w, sequence, None)
else:
funcs = self.tk.call('bind', self._w, sequence, None).split('\n')
keep = '\n'.join(f for f in funcs.split('\n')
if not f.startswith(f'if {{"[{funcid}'))
self.tk.call('bind', self._w, sequence, keep)
self.deletecommand(funcid)


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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/python/cpython/pull/17954#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a short description, not a link.

There will be a link to the corresponded issue on the tracker in any case.