[Tutor] Tk -- which label clicked
klappnase at freenet.de
Fri Jul 15 18:31:48 CEST 2005
On Fri, 15 Jul 2005 23:29:22 +1200 (NZST)
jfouhy at paradise.net.nz wrote:
> Quoting Michael Lange <klappnase at freenet.de>:
> > I don't think it will work this way, because you don't catch the event
> > bind() passes to the callback
> > (you also use a variable "e" in makeCallback() that isn't defined
> > anywhere).
> That's what the variable 'e' is doing!
> Here is some code I just wrote and tested:
> >>> def clicked(w):
> ... print 'Widget %s clicked! Text: %s' % (str(w), w.cget('text'))
> >>> def makeCallback(w):
> ... def callback(e):
> ... clicked(w)
> ... return callback
Aah, you're right, I guess I got confused a little.
Still I think it's overly complicated in this context, when you can you get the same result with:
print "Widget %s clicked! Text %s" % (str(event.widget), event.widget['text'])
More information about the Tutor