From ef8f88101a800e4e044e4ee602821a42f64f3dea Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 8 Aug 1994 12:47:33 +0000 Subject: [PATCH] Add Widget.unbind and {Canvas,Text}.tag_unbind. In Widget.__init__, call config only if cnf not empty. --- Lib/lib-tk/Tkinter.py | 11 +++++++++-- Lib/tkinter/Tkinter.py | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py index e75b0d44da1..5a2e6b28e11 100644 --- a/Lib/lib-tk/Tkinter.py +++ b/Lib/lib-tk/Tkinter.py @@ -316,6 +316,8 @@ def update(self): self.tk.call('update') def update_idletasks(self): self.tk.call('update', 'idletasks') + def unbind(self, sequence): + self.tk.call('bind', self._w, sequence, '') def bind(self, sequence, func, add=''): if add: add = '+' name = self._register(func, self._substitute) @@ -644,7 +646,8 @@ def __init__(self, master, widgetName, cnf={}, extra=()): Widget._setup(self, master, cnf) self.widgetName = widgetName apply(self.tk.call, (widgetName, self._w) + extra) - Widget.config(self, cnf) + if cnf: + Widget.config(self, cnf) def config(self, cnf=None): cnf = _cnfmerge(cnf) if cnf is None: @@ -749,7 +752,9 @@ def addtag_withtag(self, tagOrId): self.addtag('withtag', tagOrId) def bbox(self, *args): return self._getints(self._do('bbox', args)) or None - def bind(self, tagOrId, sequence, func, add=''): + def tag_unbind(self, tagOrId, sequence): + self.tk.call(self._w, 'bind', tagOrId, sequence, '') + def tag_bind(self, tagOrId, sequence, func, add=''): if add: add='+' name = self._register(func, self._substitute) self.tk.call(self._w, 'bind', tagOrId, sequence, @@ -1101,6 +1106,8 @@ def scan_dragto(self, y): def tag_add(self, tagName, index1, index2=None): self.tk.call( self._w, 'tag', 'add', tagName, index1, index2) + def tag_unbind(self, tagName, sequence): + self.tk.call(self._w, 'tag', 'bind', tagName, sequence, '') def tag_bind(self, tagName, sequence, func, add=''): if add: add='+' name = self._register(func, self._substitute) diff --git a/Lib/tkinter/Tkinter.py b/Lib/tkinter/Tkinter.py index e75b0d44da1..5a2e6b28e11 100755 --- a/Lib/tkinter/Tkinter.py +++ b/Lib/tkinter/Tkinter.py @@ -316,6 +316,8 @@ def update(self): self.tk.call('update') def update_idletasks(self): self.tk.call('update', 'idletasks') + def unbind(self, sequence): + self.tk.call('bind', self._w, sequence, '') def bind(self, sequence, func, add=''): if add: add = '+' name = self._register(func, self._substitute) @@ -644,7 +646,8 @@ def __init__(self, master, widgetName, cnf={}, extra=()): Widget._setup(self, master, cnf) self.widgetName = widgetName apply(self.tk.call, (widgetName, self._w) + extra) - Widget.config(self, cnf) + if cnf: + Widget.config(self, cnf) def config(self, cnf=None): cnf = _cnfmerge(cnf) if cnf is None: @@ -749,7 +752,9 @@ def addtag_withtag(self, tagOrId): self.addtag('withtag', tagOrId) def bbox(self, *args): return self._getints(self._do('bbox', args)) or None - def bind(self, tagOrId, sequence, func, add=''): + def tag_unbind(self, tagOrId, sequence): + self.tk.call(self._w, 'bind', tagOrId, sequence, '') + def tag_bind(self, tagOrId, sequence, func, add=''): if add: add='+' name = self._register(func, self._substitute) self.tk.call(self._w, 'bind', tagOrId, sequence, @@ -1101,6 +1106,8 @@ def scan_dragto(self, y): def tag_add(self, tagName, index1, index2=None): self.tk.call( self._w, 'tag', 'add', tagName, index1, index2) + def tag_unbind(self, tagName, sequence): + self.tk.call(self._w, 'tag', 'bind', tagName, sequence, '') def tag_bind(self, tagName, sequence, func, add=''): if add: add='+' name = self._register(func, self._substitute)