tkinter, event.widget, what do i get?

bockman at virgilio.it bockman at virgilio.it
Wed Apr 16 03:04:07 EDT 2008


On 16 Apr, 01:45, skanem... at yahoo.se wrote:
> On 16 Apr, 00:24, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
>
>
>
>
>
> > En Tue, 15 Apr 2008 17:45:08 -0300, <skanem... at yahoo.se> escribió:
>
> > > when calling function hmm here, what do i get? the widget i clicked
> > > on?
> > > if i have a canvs on wich i have a bitmap and i click on the bitmap,
> > > is the event.widget then the bitmap?
> > > can i get info about the bitmap then? like color of the pixel i
> > > clicked. if so, how?
>
> > > w.bind("<Key>", key)
> > > w.bind("<Button-1>", hmm)
>
> > > def hmm(event):
> > >     return event.widget
>
> > Why don't you try by yourself? You can use: print repr(something)
>
> > --
> > Gabriel Genellina
>
> i get <Tkinter.Canvas instance at 0x01B9B6E8>
>
> thing is i get that even though i click outside the image.
> and what can i do with this number anyway?- Nascondi testo tra virgolette -
>
> - Mostra testo tra virgolette -

If your image is a canvas item (i.e. created with canvas create_image
method), then you can use
the method tag_bind to handle events specific of that item.
In that case, the callback argument is a Tkinter.Event instance.

Ciao
-----
FB



More information about the Python-list mailing list