alessandro
alessandro

Reputation: 3984

bind event to create_image

I discovered that in Tkinter there is a limit to the maximum canvas size available: SO:tkinter maximum canvas size?

BUT this limit his hit when placing stuff by grid (I dont know about pack or place): a counterexample by Sun Bear shows that cv.create_image is unaffected.

The problem is that the images I want to show have to be bound to a mouseclick - that's the reason I was grid-ding buttons. The question is, can I create by this function something similar to a button, able at least to respond to Button-1 ?

From infohost I see that cv.create_image returns the integer ID number of the image object - can I use it to bind to it?

Upvotes: 1

Views: 477

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386030

From infohost I see that cv.create_image returns the integer ID number of the image object - can I use it to bind to it?

Yes, this is a documented feature. You can use the tag_bind method:

image_id = canvas.create_image(x, y, image=the_image)
canvas.tag_bind(image_id, "<1>", clickHandler)

Upvotes: 2

Related Questions