Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   how to get id of a line from his coordonée in tkinter python? (http://www.velocityreviews.com/forums/t958527-how-to-get-id-of-a-line-from-his-coordonee-in-tkinter-python.html)

olsr.kamal@gmail.com 03-09-2013 10:46 PM

how to get id of a line from his coordonée in tkinter python?
 
how to get id of a line from his coordonée in tkinter python?

Rick Johnson 03-09-2013 11:40 PM

Re: how to get id of a line from his coordonée in tkinter python?
 
On Saturday, March 9, 2013 4:46:40 PM UTC-6, olsr....@gmail.com wrote:
> how to get id of a line from his coordonée in tkinter python?


Each time you create a "canvas item", be it a rectangle, line, circle, or whatever..., the id of that object is returned as an integer. All you have to do is save the id into a variable.

rectID = canvas.create_rectangle(...)

Now you can pass that unique id into many of the methods that exist for "canvas items".

canvas.delete(rectID)
canvas.coords(rectID)
canvas.bbox(rectID)

*Sarcastic Sam quipped*: """Rick, not everybody can be as smart as you! What if we forgot to save the return value into a variable? Besides, you cannot expect us to create a variable to hold *every single* id of *every single* canvas object; that would be ridiculous!"""

Indeed it would Sam. Besides, integer tags are not easy to remember, and they are created by the canvas object (which is out of your control).

But before you throw the computer out the window, be aware that the canvas allows you to tag each "canvas item" by passing one or more strings, using the "tags=..." argument, into the "canvas.create_X(args)" methods.

py> canvas.create_rectangle(0,0,10,10, fill='red', tags='red_rect')
py> canvas.coords('red_rect')
(0,0,10,10)

PS: Hopefully you solved that other issue.


All times are GMT. The time now is 12:19 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.