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

Skip to content

Commit eb354b3

Browse files
committed
Bug reported by Jim Robinson:
An attempt to execute grid_slaves with arguments (0,0) results in *all* of the slaves being returned, not just the slave associated with row 0, column 0. This is because the test for arguments in the method does not test to see if row (and column) does not equal None, but rather just whether is evaluates to non-false. A value of 0 fails this test.
1 parent 8d2c0c2 commit eb354b3

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

Lib/lib-tk/Tkinter.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,9 +714,9 @@ def grid_size(self):
714714
size = grid_size
715715
def grid_slaves(self, row=None, column=None):
716716
args = ()
717-
if row:
717+
if row is not None:
718718
args = args + ('-row', row)
719-
if column:
719+
if column is not None:
720720
args = args + ('-column', column)
721721
return map(self._nametowidget,
722722
self.tk.splitlist(self.tk.call(
@@ -1156,6 +1156,7 @@ def At(x, y=None):
11561156
return '@' + `x` + ',' + `y`
11571157

11581158
class Canvas(Widget):
1159+
_tagcommands = None
11591160
def __init__(self, master=None, cnf={}, **kw):
11601161
Widget.__init__(self, master, 'canvas', cnf, kw)
11611162
def addtag(self, *args):
@@ -1182,8 +1183,16 @@ def tag_unbind(self, tagOrId, sequence, funcid=None):
11821183
if funcid:
11831184
self.deletecommand(funcid)
11841185
def tag_bind(self, tagOrId, sequence=None, func=None, add=None):
1185-
return self._bind((self._w, 'bind', tagOrId),
1186-
sequence, func, add)
1186+
res = self._bind((self._w, 'bind', tagOrId),
1187+
sequence, func, add)
1188+
if sequence and func and res:
1189+
# remember the funcid for later
1190+
if self._tagcommands is None:
1191+
self._tagcommands = {}
1192+
list = self._tagcommands.get(tagOrId) or []
1193+
self._tagcommands[tagOrId] = list
1194+
list.append(res)
1195+
return res
11871196
def canvasx(self, screenx, gridspacing=None):
11881197
return getdouble(self.tk.call(
11891198
self._w, 'canvasx', screenx, gridspacing))
@@ -1227,7 +1236,16 @@ def create_window(self, *args, **kw):
12271236
def dchars(self, *args):
12281237
self.tk.call((self._w, 'dchars') + args)
12291238
def delete(self, *args):
1239+
self._delete_bindings(args)
12301240
self.tk.call((self._w, 'delete') + args)
1241+
def _delete_bindings(self, args):
1242+
for tag in args:
1243+
for a in self.tag_bind(tag):
1244+
b = self.tag_bind(tag, a)
1245+
c = _string.split(b, '[')[1]
1246+
d = _string.split(c)[0]
1247+
print "deletecommand(%s)" % `d`
1248+
self.deletecommand(d)
12311249
def dtag(self, *args):
12321250
self.tk.call((self._w, 'dtag') + args)
12331251
def find(self, *args):

0 commit comments

Comments
 (0)