Newbie question Canvas or frame

In ruby-tk

Do you need a canvas to show a picture or is it ok to
show a picture on a frame?

When should you use a canvas?

···

--
Posted via http://www.ruby-forum.com/.

Mer Gilmartin wrote:

In ruby-tk
Do you need a canvas to show a picture or is it ok to
show a picture on a frame?
When should you use a canvas?

Ok. canvas is needed to display picture.
but i still would like to hear peoples comments about
canvases and frames to understand them better.

···

--
Posted via http://www.ruby-forum.com/\.

Message-ID: <183e167ef809521c53ea5d9bded5682e@ruby-forum.com>

In ruby-tk
Do you need a canvas to show a picture or is it ok to
show a picture on a frame?

If you want to show a picture only, you don't need a canvas widget.
Please create a TkPhotoImage object and assign it to `image' option
of a TkLabel object (or a widget which has `image' option).

Current standard Tcl/Tk suuports only GIF and PPM/PGM formats.
If you want to treat other formats (JPEG, BMP, and so on), you need
to use `TkImg' extension (ActiveTcl package already includes it).
Current Ruby/Tk supports TkImg extension.

When should you use a canvas?

There are many cases.

* When needs a drawing field (and save it by Postscrpt format).

* When want to handle widgets or canvas items (Line, Oval, and so on)
  by coordinates.
  Please see the example "Ruby/Tk widget demo" which is included in
  Ruby source archive.

* When want to assign bindings to some parts of a picture
  (e.g. a tree picture which has clickable branches).

* When want to create a scrollable frame.
  Please see the example "ext/tk/sample/scrollframe.rb" on Ruby
  source tree.

# On Ruby/TkORCA, a canvas widget takes place of a pseudo window
# manager for slave Ruby/Tk applications.

···

From: Mer Gilmartin <merrua@yahoo.co.uk>
Subject: Newbie question Canvas or frame
Date: Tue, 10 Oct 2006 19:19:28 +0900
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

Hidetoshi NAGAI wrote:

If you want to show a picture only, you don't need a canvas widget.
Please create a TkPhotoImage object and assign it to `image' option
of a TkLabel object (or a widget which has `image' option).

Ah. Im using TkPhotoImage with canvas and a frame. Is this ok ?

And the `TkImg' extension, do I add that with require "TKImg".
I have active tcl on the computer.

···

--
Posted via http://www.ruby-forum.com/\.

Message-ID: <6cc68269b8f4191b460819f3e29422b6@ruby-forum.com>

Ah. Im using TkPhotoImage with canvas and a frame. Is this ok ?

That is OK, if that is what you want. :slight_smile:

And the `TkImg' extension, do I add that with require "TKImg".
I have active tcl on the computer.

Please use "require 'tkextlib/tkimg'".
If your Ruby/Tk loads libraries of ActiveTcl, that will work.

···

From: Mer Gilmartin <merrua@yahoo.co.uk>
Subject: Re: Newbie question Canvas or frame
Date: Tue, 10 Oct 2006 23:20:40 +0900
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

Thank You!

···

--
Posted via http://www.ruby-forum.com/.