Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef8f881

Browse files
committed
Add Widget.unbind and {Canvas,Text}.tag_unbind.
In Widget.__init__, call config only if cnf not empty.
1 parent 16d6e71 commit ef8f881

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

Lib/lib-tk/Tkinter.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ def update(self):
316316
self.tk.call('update')
317317
def update_idletasks(self):
318318
self.tk.call('update', 'idletasks')
319+
def unbind(self, sequence):
320+
self.tk.call('bind', self._w, sequence, '')
319321
def bind(self, sequence, func, add=''):
320322
if add: add = '+'
321323
name = self._register(func, self._substitute)
@@ -644,7 +646,8 @@ def __init__(self, master, widgetName, cnf={}, extra=()):
644646
Widget._setup(self, master, cnf)
645647
self.widgetName = widgetName
646648
apply(self.tk.call, (widgetName, self._w) + extra)
647-
Widget.config(self, cnf)
649+
if cnf:
650+
Widget.config(self, cnf)
648651
def config(self, cnf=None):
649652
cnf = _cnfmerge(cnf)
650653
if cnf is None:
@@ -749,7 +752,9 @@ def addtag_withtag(self, tagOrId):
749752
self.addtag('withtag', tagOrId)
750753
def bbox(self, *args):
751754
return self._getints(self._do('bbox', args)) or None
752-
def bind(self, tagOrId, sequence, func, add=''):
755+
def tag_unbind(self, tagOrId, sequence):
756+
self.tk.call(self._w, 'bind', tagOrId, sequence, '')
757+
def tag_bind(self, tagOrId, sequence, func, add=''):
753758
if add: add='+'
754759
name = self._register(func, self._substitute)
755760
self.tk.call(self._w, 'bind', tagOrId, sequence,
@@ -1101,6 +1106,8 @@ def scan_dragto(self, y):
11011106
def tag_add(self, tagName, index1, index2=None):
11021107
self.tk.call(
11031108
self._w, 'tag', 'add', tagName, index1, index2)
1109+
def tag_unbind(self, tagName, sequence):
1110+
self.tk.call(self._w, 'tag', 'bind', tagName, sequence, '')
11041111
def tag_bind(self, tagName, sequence, func, add=''):
11051112
if add: add='+'
11061113
name = self._register(func, self._substitute)

Lib/tkinter/Tkinter.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ def update(self):
316316
self.tk.call('update')
317317
def update_idletasks(self):
318318
self.tk.call('update', 'idletasks')
319+
def unbind(self, sequence):
320+
self.tk.call('bind', self._w, sequence, '')
319321
def bind(self, sequence, func, add=''):
320322
if add: add = '+'
321323
name = self._register(func, self._substitute)
@@ -644,7 +646,8 @@ def __init__(self, master, widgetName, cnf={}, extra=()):
644646
Widget._setup(self, master, cnf)
645647
self.widgetName = widgetName
646648
apply(self.tk.call, (widgetName, self._w) + extra)
647-
Widget.config(self, cnf)
649+
if cnf:
650+
Widget.config(self, cnf)
648651
def config(self, cnf=None):
649652
cnf = _cnfmerge(cnf)
650653
if cnf is None:
@@ -749,7 +752,9 @@ def addtag_withtag(self, tagOrId):
749752
self.addtag('withtag', tagOrId)
750753
def bbox(self, *args):
751754
return self._getints(self._do('bbox', args)) or None
752-
def bind(self, tagOrId, sequence, func, add=''):
755+
def tag_unbind(self, tagOrId, sequence):
756+
self.tk.call(self._w, 'bind', tagOrId, sequence, '')
757+
def tag_bind(self, tagOrId, sequence, func, add=''):
753758
if add: add='+'
754759
name = self._register(func, self._substitute)
755760
self.tk.call(self._w, 'bind', tagOrId, sequence,
@@ -1101,6 +1106,8 @@ def scan_dragto(self, y):
11011106
def tag_add(self, tagName, index1, index2=None):
11021107
self.tk.call(
11031108
self._w, 'tag', 'add', tagName, index1, index2)
1109+
def tag_unbind(self, tagName, sequence):
1110+
self.tk.call(self._w, 'tag', 'bind', tagName, sequence, '')
11041111
def tag_bind(self, tagName, sequence, func, add=''):
11051112
if add: add='+'
11061113
name = self._register(func, self._substitute)

0 commit comments

Comments
 (0)