Tk canvas widget Id's

Is it possible to access the Id’s of objects declared within a Tk canvas
widget?

In Ruby

item = TkcOval.new(parameters)

returns a reference to the object. How can I get the Id? Thanks

John

item.id # this will return the id of the item

Dave

···

John Fletcher J.P.Fletcher@aston.ac.uk wrote:
Is it possible to access the Id’s of objects declared within a Tk canvas
widget?

In Ruby

item = TkcOval.new(parameters)

returns a reference to the object. How can I get the Id? Thanks

John


Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

D T wrote:

item.id # this will return the id of the item Dave

O.K. I can make that work and it gives a small integer value. Later I
want to find the Id of an object I have clicked on and made current.

q = w.find_withtag ‘current’
puts q # Gives the same object address as for the item previously
puts q.id # This gives garbage which changes.

Is there something else wrong?

John

Hi John,

q = w.find_withtag 'current’
q will hold an array object, because it can be many objects associate
to the same ‘tag’, even there is only one like ‘current’.
The find_withtag always return an array object.
q.id # you are calling array’s id method, not Tk’s method.
q[0].id # this should work in your case.

Dave

···

John Fletcher J.P.Fletcher@aston.ac.uk wrote:

q = w.find_withtag 'current’
puts q # Gives the same object address as for the item previously
puts q.id # This gives garbage which changes.

Is there something else wrong?

John


Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

D T wrote:

Hi John, q = w.find_withtag 'current’q will hold an array object,
because it can be many objects associateto the same ‘tag’, even there
is only one like ‘current’.The find_withtag always return an array
object.q.id # you are calling array’s id method, not Tk’s
method.q[0].id # this should work in your case. Dave

Dave

Thanks for this. An explanation at last. I have been unable to track
down a manual for this. Thanks again

John