CanvasText issues

Salim Zayat zayats at blue.seas.upenn.edu
Wed May 29 11:45:33 EDT 2002


If I want to add extra info to a CanvasText instance, should I just 
include it as a tag, or should I write some sort of a superclass around 
the CanvasText?  IF the latter is better, how can I get that extra piece 
of info from the Canvas?  For example, I wrote a superclass CText:

class CText(CanvasText):
        def __init__(self, canvas, x, y, data, **kw):
                CanvasText.__init__(self, canvas, x, y, kw)
                self.data = data

but now I want to get that self.data from a callback function bound to 
the canvas (as opposed to tag_binded to every CText) with something like 
this:

def cb(event, c=canvas):
	if c.type('active') == 'text':
		DO SOMETHING
	else:
		pass

canvas.bind('<Button-1>', cb)


I have been trying to figure that problem out, and in doing such 
discovered just loading up the tags.  So if that is the best way, so be 
it.  I just wanted to get some more opinions before I committed to one way.

Salim



More information about the Python-list mailing list