Canvas Group object

Mike Olson athos84 at my-deja.com
Mon Aug 7 12:01:23 EDT 2000


I am having an impossble time trying to get the the Canvas Group object
to work.  Can anyone help me debug this code?  It only binds the
callback to clicking on the text, and not the rectangle, and I can't see
what I'm doing differently from all the examples I've seen:

from Tkinter import *
from Canvas import *
from Canvas import Group

class Card:
	def __init__(self, master):
		canvas = self.canvas = Canvas(master)
		canvas.pack()
		text="A Hearts"
		self.group = Group(canvas)
		self.rect = self.canvas.create_rectangle(10, 10, 85, 122, tags=text)
		self.txt = self.canvas.create_text(46, 15, text=text, tags=text)
		self.group.addtag_withtag(self.rect)
		self.group.addtag_withtag(self.txt)
		self.group.bind("<Button-1>", self.callback)

	def callback(self, event=None):
		self.canvas.itemconfigure(self.rect, fill='red')

root = Tk()
app = Card(root)
mainloop()


--
Mike Olson
Provis Corporation
Columbia Heights, MN


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list