Where is TkcGrid?

Hello,

In Perl/Tk, tha canvas has a grid item type. Is this item type missing
from
the Ruby/Tk port? Using

TkcGrid.new([0,0], [10,10])

results in

./test.rb:17: uninitialized constant TkcGrid (NameError)

Any hints?

Josef W. wrote:

Any hints?

TkGrid is used in many of the samples: sample/scrollframe.rb, for
example.

On Thu, Sep 10, 2009 at 02:37:43AM +0900, Joel VanderWerf wrote:

Any hints?

TkGrid is used in many of the samples: sample/scrollframe.rb, for example.

Thanks for your reply, Joel!

I am talking about the TkcGrid item type of the canvas widget and not
about
the TkGrid geometry manager. The TkcGrid item type draws little dots
with
a regular distance into the canvas.

Josef W. wrote:

Any hints?
TkGrid is used in many of the samples: sample/scrollframe.rb, for example.

Thanks for your reply, Joel!

I am talking about the TkcGrid item type of the canvas widget and not about
the TkGrid geometry manager. The TkcGrid item type draws little dots with
a regular distance into the canvas.

Oh, sorry! I don’t know, then. I’ve always constructed my own grids[1],
so if you find the answer, let us know…

How is the perl class implemented? Google doesn’t have any hits for
‘TkcGrid perl tk’, except your post.

[1] see mkgrid.rb in tkar/sample

On Thu, Sep 10, 2009 at 04:04:10AM +0900, Joel VanderWerf wrote:

./test.rb:17: uninitialized constant TkcGrid (NameError)
Oh, sorry! I don’t know, then. I’ve always constructed my own grids[1], so
if you find the answer, let us know…

The grid item has some advantages over a matrix of dots:

  • you don’t have to know in advance how big your canvas will be
  • it automatically covers the whole cnavas whenever you resize it
  • the grid dots never overlap other items
  • grid dots will never be returned by search operations
  • it is much more efficient than a matrix of dots. Having a canvas with
    10^6 dots makes a significant difference :slight_smile:

How is the perl class implemented?

I have no idea. I could not find any hints about that in my
/usr/lib/perl5
directory, so I assume it is implemented in the C bindings.

Google doesn’t have any hits for ‘TkcGrid perl tk’, except your post.

Well, perl’s naming conventions for Tk are different from Ruby’s. Things
like TkcXxxxx simply do not exist in Perl/Tk :wink:

You might check section 9.6.10 in
http://docstore.mik.ua/orelly/perl3/tk/ch09_06.htm

Here’s the first part of the description from the Tk::Canvas man page

GRID ITEMS
Items of type grid are intended for producing a visual reference for
interpreting other items. They can be drawn as either lines (with
dash
style) or as rectangular “dots” at each grid point.

Items of type grid are unlike other items they always cover the whole
of the canvas, but are never enclosed by nor overlap any area and are
not near any point. That is they are intended to be always visible
but
not “pickable”, as such they do support the “active” state. They are
like other items in that: multiple grids are permitted, they can be
raised and lowered relative to other items, they can be moved and
scaled. As yet grids do not apear in PostScript output.

Grids have outline like configure options. Grids are created with
methods of the following form:

$canvas->createGrid(x1, y1, x2, y2, ?option, value, option, value, 

…?)

The arguments x1, y1 give the origin of the grid. x2, and y2 give the
coordinates of the next grid point in their respective directions.
After the coordinates there may be any number of option-value pairs,
each of which sets one of the configuration options for the item.
These same option-value pairs may be used in itemconfigure methods to
change the item’s configuration. The following options are supported
for grids:

[ … ]