Updated 2011-07-25 11:50:45 by RLE


   tscanvas - an extension of the canvas widget


   tscanvas pathName ?options?

  tscanvas (Tiled-Scrolling-canvas) is an extension of the canvas widget.
  A Tiled-Scrolling-canvas is simply a canvas with an image item acting as background.
  Horizontal and vertical scrollbars are provided by default.

   all "canvas" options are supported.

  -bgimage _image_
    Specifies an image to display as background, which must have been created
    with the "image create" command.
    If _image_ is the empty string, the background is disabled
  -bgzoom _n_
    _n_ is an integer value (default 1). With this option, each pixel in the
    source image will be expanded into a block of n x n pixels.
  -bgmargin _n_
    _n_ is an integer value ( _n_ >= 0 ; default is 0).
    the background image will cover all the canvas visible surface,
    leaving a margin of _n_ pixels.
  -hscrollside _side_
    Specifies where to place the horizontal scrollbar.
    _side_ can be: "top","bottom","none" .
    Default is "bottom".
  -vscrollside _side_
    Specifies where to place the vertical scrollbar.
    _side_ can be: "left","right","none" .
    Default is "right".

   .. all "canvas" widget commands are supported.

   pathName clean
    delete all items on canvas (leaving the background-image intact)
   pathName frame cget _option_
    queries the "container" frame (i.e. the frame containing the 'primitive'
    canvas and the two scrollbars) and returns the configuration option
    given by _option_.
    Option may have any of the values accepted by the frame command.
   pathName frame configure ?_option_ ?_value_ _option_ _value_ ...?
    queries or modifies the "container" frame (i.e. the frame containing
    the 'primitive' canvas and the two scrollbars).
    _option_ and _value_ may have any of the values accepted by the frame

Read more:

  • README.txt [1]
  • tscanvas.txt [2]


  • tscanvas1.0.zip [3] This url throws a "Forbidden" error

Question - have you considered submitting these megawidgets to tklib?

PWQ 20 Feb 04, Don't mean to be picky, but since this widget masquerades as a canvas widget, shouldn't it do the tag conversions to prevent matching the background, rather than the programmer?

I have looked at the code, and now I will be picky. The background image is placed over the entire scrollregion of the canvas. In some applications this is could be enormous. A more efficient approach is to make the background one tile bigger than the visible size and move it with the canvas scrolling.

In case you thinking this doesn't actually matter, Netscape 4 when rendering a page creates a bitmap for the entire page, even though only a fraction of the page is visible. On very simple but long pages you can run out of memory and segfault trying to view them.

What happens if I have a canvas that has a scroll region of {-100000 -100000 100000 100000} and pans automatically to the place of interest under program (rather than scrollbar) control? (Example a map viewer.)

ABU 26-jan-2005 (.. sorry to be late ..)

Within the Paved Widgets package you can find a new widget Paved::canvas able to manage such huge scrollregions as you suggested.