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

Skip to content

Commit 178ff35

Browse files
committed
Fix bogus implementation of Group.bind().
Added unbind() to CanvasItem and Group classes.
1 parent 8371013 commit 178ff35

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

Lib/lib-tk/Canvas.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def bbox(self):
4343
return (x1, y1), (x2, y2)
4444
def bind(self, sequence=None, command=None):
4545
return self.canvas.tag_bind(self.id, sequence, command)
46+
def unbind(self, sequence):
47+
self.canvas.tag_bind(self.id, sequence, '')
4648
def config(self, cnf={}, **kw):
4749
return self.canvas.itemconfig(self.id, _cnfmerge((cnf, kw)))
4850
def coords(self, pts = ()):
@@ -140,8 +142,10 @@ def addtag_withtag(self, tagOrId):
140142
self._do('addtag', 'withtag', tagOrId)
141143
def bbox(self):
142144
return self._getints(self._do('bbox'))
143-
def bind(self, sequence=None, command=None): # XXX args?
144-
return self._do('bind', sequence, command)
145+
def bind(self, sequence=None, command=None):
146+
return self.canvas.tag_bind(self.id, sequence, command)
147+
def unbind(self, sequence):
148+
self.canvas.tag_bind(self.id, sequence, '')
145149
def coords(self, *pts):
146150
return self._do('coords', pts)
147151
def dchars(self, first, last=None):

Lib/tkinter/Canvas.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def bbox(self):
4343
return (x1, y1), (x2, y2)
4444
def bind(self, sequence=None, command=None):
4545
return self.canvas.tag_bind(self.id, sequence, command)
46+
def unbind(self, sequence):
47+
self.canvas.tag_bind(self.id, sequence, '')
4648
def config(self, cnf={}, **kw):
4749
return self.canvas.itemconfig(self.id, _cnfmerge((cnf, kw)))
4850
def coords(self, pts = ()):
@@ -140,8 +142,10 @@ def addtag_withtag(self, tagOrId):
140142
self._do('addtag', 'withtag', tagOrId)
141143
def bbox(self):
142144
return self._getints(self._do('bbox'))
143-
def bind(self, sequence=None, command=None): # XXX args?
144-
return self._do('bind', sequence, command)
145+
def bind(self, sequence=None, command=None):
146+
return self.canvas.tag_bind(self.id, sequence, command)
147+
def unbind(self, sequence):
148+
self.canvas.tag_bind(self.id, sequence, '')
145149
def coords(self, *pts):
146150
return self._do('coords', pts)
147151
def dchars(self, first, last=None):

0 commit comments

Comments
 (0)