Commit eb354b31 authored by Guido van Rossum's avatar Guido van Rossum

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.
parent 8d2c0c2a
...@@ -714,9 +714,9 @@ class Misc: ...@@ -714,9 +714,9 @@ class Misc:
size = grid_size size = grid_size
def grid_slaves(self, row=None, column=None): def grid_slaves(self, row=None, column=None):
args = () args = ()
if row: if row is not None:
args = args + ('-row', row) args = args + ('-row', row)
if column: if column is not None:
args = args + ('-column', column) args = args + ('-column', column)
return map(self._nametowidget, return map(self._nametowidget,
self.tk.splitlist(self.tk.call( self.tk.splitlist(self.tk.call(
...@@ -1156,6 +1156,7 @@ def At(x, y=None): ...@@ -1156,6 +1156,7 @@ def At(x, y=None):
return '@' + `x` + ',' + `y` return '@' + `x` + ',' + `y`
class Canvas(Widget): class Canvas(Widget):
_tagcommands = None
def __init__(self, master=None, cnf={}, **kw): def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, 'canvas', cnf, kw) Widget.__init__(self, master, 'canvas', cnf, kw)
def addtag(self, *args): def addtag(self, *args):
...@@ -1182,8 +1183,16 @@ class Canvas(Widget): ...@@ -1182,8 +1183,16 @@ class Canvas(Widget):
if funcid: if funcid:
self.deletecommand(funcid) self.deletecommand(funcid)
def tag_bind(self, tagOrId, sequence=None, func=None, add=None): def tag_bind(self, tagOrId, sequence=None, func=None, add=None):
return self._bind((self._w, 'bind', tagOrId), res = self._bind((self._w, 'bind', tagOrId),
sequence, func, add) sequence, func, add)
if sequence and func and res:
# remember the funcid for later
if self._tagcommands is None:
self._tagcommands = {}
list = self._tagcommands.get(tagOrId) or []
self._tagcommands[tagOrId] = list
list.append(res)
return res
def canvasx(self, screenx, gridspacing=None): def canvasx(self, screenx, gridspacing=None):
return getdouble(self.tk.call( return getdouble(self.tk.call(
self._w, 'canvasx', screenx, gridspacing)) self._w, 'canvasx', screenx, gridspacing))
...@@ -1227,7 +1236,16 @@ class Canvas(Widget): ...@@ -1227,7 +1236,16 @@ class Canvas(Widget):
def dchars(self, *args): def dchars(self, *args):
self.tk.call((self._w, 'dchars') + args) self.tk.call((self._w, 'dchars') + args)
def delete(self, *args): def delete(self, *args):
self._delete_bindings(args)
self.tk.call((self._w, 'delete') + args) self.tk.call((self._w, 'delete') + args)
def _delete_bindings(self, args):
for tag in args:
for a in self.tag_bind(tag):
b = self.tag_bind(tag, a)
c = _string.split(b, '[')[1]
d = _string.split(c)[0]
print "deletecommand(%s)" % `d`
self.deletecommand(d)
def dtag(self, *args): def dtag(self, *args):
self.tk.call((self._w, 'dtag') + args) self.tk.call((self._w, 'dtag') + args)
def find(self, *args): def find(self, *args):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment