Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

need scrollbar help

5 views
Skip to first unread message

mitch

unread,
Oct 21, 2005, 2:12:01 PM10/21/05
to
# I want to scroll a big canvas inside of a smaller frame
# what am I doing wrong ?
# , when I run this , the scrollbar looks (and is ) dead.
# thanks ...M'


frame .top -width 800 -height 600
canvas .top.c -width 1800 -height 1600 -yscrollcommand {.top.s set}
scrollbar .top.s -command { .top.c yview } -orient vert

pack .top
pack .top.c -side left
pack .top.s -side right -fill y -expand 1

Bryan Oakley

unread,
Oct 21, 2005, 2:51:22 PM10/21/05
to
mitch wrote:
> # I want to scroll a big canvas inside of a smaller frame
> # what am I doing wrong ?

You need to set the -scrollregion option of the canvas, typically with
something like ".t.c configure -scrollregion [.t.c bbox all]".

mitch

unread,
Oct 21, 2005, 3:18:26 PM10/21/05
to
That doesn't seem to change anything...
what I am trying to do is display a small window, containing a large canvas. (only the
portion of the canvas under the small window will be visible.) The canvas will contain
many "items". I want to be able to move around the canvas like a map, to get to the
different parts of the canvas where the various Items are .

...M'

Bryan Oakley

unread,
Oct 21, 2005, 4:19:26 PM10/21/05
to
mitch wrote:
> That doesn't seem to change anything...
> what I am trying to do is display a small window, containing a large
> canvas. (only the portion of the canvas under the small window will be
> visible.) The canvas will contain many "items". I want to be able to
> move around the canvas like a map, to get to the different parts of the
> canvas where the various Items are .

What you're saying is you want to move the 1800x1600 canvas around
inside the frame? It's possible (search the wiki for scrollable frames),
but I don't think that is necessary in this case.

If you want to draw in a 1800x1600 area but only view 800x600 at a time,
just make your canvas be 800x600 and the scrollregion 1800x1600. This
gives you an 800x600 viewport into a 1800x1600 drawable area. With that,
you don't need the surrounding frame (except maybe for aesthetic or
layout reasons)

canvas .top.c -width 800 -height 600 -scrollregion {0 0 1600 1800}

mitch

unread,
Oct 21, 2005, 3:54:13 PM10/21/05
to
OK,
so if I wanted to place an Item just out of view to the right of the "viewable
window", I would place it on the canvas at canvas coordinate 900 200. ??

Then I could scroll right to see that Item?
(assuming canvas 0,0 is at upper, left)

(thanks for the help on this , scrollbars drive me nuts )
...M'

Bryan Oakley

unread,
Oct 21, 2005, 5:01:52 PM10/21/05
to
mitch wrote:
> OK,
> so if I wanted to place an Item just out of view to the right of the
> "viewable window", I would place it on the canvas at canvas coordinate
> 900 200. ??

Yes.

>
> Then I could scroll right to see that Item?
> (assuming canvas 0,0 is at upper, left)

yes.

0 new messages