diff options
author | Guido van Rossum <guido@python.org> | 1998-03-27 21:26:51 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-03-27 21:26:51 (GMT) |
commit | 117a5a8138c42158c7917e923d1be5a14d051e59 (patch) | |
tree | 53d81318d97031ebf01cb258531a4505ecaf9b6e /Lib | |
parent | 982d91fb51d1578fef12152e262130caa9f89504 (diff) | |
download | cpython-117a5a8138c42158c7917e923d1be5a14d051e59.zip cpython-117a5a8138c42158c7917e923d1be5a14d051e59.tar.gz cpython-117a5a8138c42158c7917e923d1be5a14d051e59.tar.bz2 |
Return the name of the Tcl command defined by _bind(). This can
optionally be passed to unbind() (or you can apss it to
deletecommand()).
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/lib-tk/Tkinter.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py index a7c01b4..63e521d 100644 --- a/Lib/lib-tk/Tkinter.py +++ b/Lib/lib-tk/Tkinter.py @@ -456,21 +456,25 @@ class Misc: self.tk.call('bindtags', self._w, tagList) def _bind(self, what, sequence, func, add, needcleanup=1): if func: + funcid = self._register(func, self._substitute, + needcleanup) cmd = ("%sset _tkinter_break [%s %s]\n" 'if {"$_tkinter_break" == "break"} break\n') \ % (add and '+' or '', - self._register(func, self._substitute, - needcleanup), + funcid, _string.join(self._subst_format)) apply(self.tk.call, what + (sequence, cmd)) + return funcid elif func == '': apply(self.tk.call, what + (sequence, func)) else: return apply(self.tk.call, what + (sequence,)) def bind(self, sequence=None, func=None, add=None): return self._bind(('bind', self._w), sequence, func, add) - def unbind(self, sequence): + def unbind(self, sequence, funcid=None): self.tk.call('bind', self._w, sequence, '') + if funcid: + self.deletecommand(funcid) def bind_all(self, sequence=None, func=None, add=None): return self._bind(('bind', 'all'), sequence, func, add, 0) def unbind_all(self, sequence): @@ -1130,8 +1134,10 @@ class Canvas(Widget): self.addtag(newtag, 'withtag', tagOrId) def bbox(self, *args): return self._getints(self._do('bbox', args)) or None - def tag_unbind(self, tagOrId, sequence): + def tag_unbind(self, tagOrId, sequence, funcid=None): self.tk.call(self._w, 'bind', tagOrId, sequence, '') + if funcid: + self.deletecommand(funcid) def tag_bind(self, tagOrId, sequence=None, func=None, add=None): return self._bind((self._w, 'bind', tagOrId), sequence, func, add) @@ -1594,8 +1600,10 @@ class Text(Widget): def tag_add(self, tagName, index1, index2=None): self.tk.call( self._w, 'tag', 'add', tagName, index1, index2) - def tag_unbind(self, tagName, sequence): + def tag_unbind(self, tagName, sequence, funcid=None): self.tk.call(self._w, 'tag', 'bind', tagName, sequence, '') + if funcid: + self.deletecommand(funcid) def tag_bind(self, tagName, sequence, func, add=None): return self._bind((self._w, 'tag', 'bind', tagName), sequence, func, add) |