Update __init__.py
Revise docstring to match behavior specified by Serhiy. Rearrange code to match.
This commit is contained in:
parent
05836401ac
commit
597ef39042
|
@ -1385,14 +1385,20 @@ class Misc:
|
|||
return self._bind(('bind', self._w), sequence, func, add)
|
||||
|
||||
def unbind(self, sequence, funcid=None):
|
||||
"""Unbind for this widget the event SEQUENCE. if
|
||||
FUNCID is given, delete the command also."""
|
||||
funcs = self.tk.call('bind', self._w, sequence, None)
|
||||
self.tk.call('bind', self._w, sequence, '')
|
||||
if funcid:
|
||||
self.deletecommand(funcid)
|
||||
keep = '\n'.join(f for f in funcs.split('\n') if not f.startswith(f'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.
|
||||
|
|
Loading…
Reference in New Issue