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?

Mer G. 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.

From: Mer G. [email protected]
Subject: Newbie question Canvas or frame
Date: Tue, 10 Oct 2006 19:19:28 +0900
Message-ID: [email protected]

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 hasimage’ 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.

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 hasimage’ 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.

Thank You!

From: Mer G. [email protected]
Subject: Re: Newbie question Canvas or frame
Date: Tue, 10 Oct 2006 23:20:40 +0900
Message-ID: [email protected]

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs