]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Return the name of the Tcl command defined by _bind(). This can
authorGuido van Rossum <guido@python.org>
Fri, 27 Mar 1998 21:26:51 +0000 (21:26 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 27 Mar 1998 21:26:51 +0000 (21:26 +0000)
optionally be passed to unbind() (or you can apss it to
deletecommand()).

Lib/lib-tk/Tkinter.py

index a7c01b4050a21067d39eaae5b2d188318e81db46..63e521d1f8bce6ee926aad1f2553ed4bda780e2f 100644 (file)
@@ -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)