Oh! Never mind; this can be a lot simpler. According to the "Gotchas" section of:
http://tkinter.unpythonic.net/wiki/Widgets/Canvas
the items in a Canvas are actually not object instances themselves, but integers. I made an assumption that canvas items were object instances, so I wrote that subtract_instances() to take care of issues with them.
?? Sets can contain any object that is usable as a dictionary key.
But if canvas items are really integers, then we don't need subtract_instances() at all. We can just use sets and subtract one set from the other. Here is a redefinition of find_withouttag() which should work better:
### from sets import Set
Note that Python 2.4 has set built-in with the name 'set'. To be compatible with both you could write try: set except NameError: from sets import Set as set
def find_withouttag(canvas, tag): """Returns all the objects that aren't tagged with 'tag'.""" all_objects = Set(canvas.find_all()) tagged_objects = Set(canvas.find_withtag(tag)) return all_objects - tagged_objects ###
or all_objects = Set(canvas.find_all()) all_objects.difference_update(canvas.find_withtag(tag)) return all_objects
Kent
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor