Get TkCanvas from an item?

If I have a Tk item like a TkcRectangle that has been created on a TkCanvas, is there a way to ask the TkcRectangle for the TkCanvas that it is on? For example, can I do something similar to this?

root = TkRoot.new {title 'Diagram'}
canvas = TkCanvas.new(root)
item = TkcRectangle.new(canvas, x, y, x + width, y + height)

the_canvas = item.canvas # not a real method

or

the_canvas = item.parent # not a real method

Hi,

ยทยทยท

From: "R. Mark Volkmann" <mark@ociweb.com>
Subject: get TkCanvas from an item?
Date: Sun, 5 Dec 2004 07:13:30 +0900
Message-ID: <04ed01c4da4e$7c330840$0200a8c0@MarkDesktop>

If I have a Tk item like a TkcRectangle that has been created on a TkCanvas,
is there a way to ask the TkcRectangle for the TkCanvas that it is on? For
example, can I do something similar to this?

If you want that, please add the following to your script.
----------------------------------------------
class TkcItem < TkObject
  def canvas; @parent; end
end
----------------------------------------------
or
----------------------------------------------
class TkcItem < TkObject
  def parent; @parent; end
end
----------------------------------------------
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)