From: ccie15672 on
All:

I've read a number of messages here on the group and I've been all
over tcl.tk and I've looked at several books... and I guess there is
something I'm missing... hopefully something obvious.

I need a very large canvas. Only a portion of which will be visible.
As I understand it, the canvas can be up to 32000x32000 pixels. When
I set the canvas to this side, the window goes wonky. I figured I
could put the canvas into a frame and limit the frame size and add
scrolling.

But the scrollbars are always greyed out, even though I can move
canvas items off the edges.

Also, I'd like to be able to resize the window (without resizing the
items on the canvas) so that more or less canvas is exposed and have
the scrollbars automatically adjust.

I see all kinds of wrappers and custom code to do this, but doesn't Tk
support this natively? I find a lot of stuff on Tcl.Tk that does
things that Tk does by itself it seems already.

Thanks...

Derick
From: Alan Grunwald on
ccie15672 wrote:

> All:
>
> I've read a number of messages here on the group and I've been all
> over tcl.tk and I've looked at several books... and I guess there is
> something I'm missing... hopefully something obvious.
>
> I need a very large canvas. Only a portion of which will be visible.
> As I understand it, the canvas can be up to 32000x32000 pixels. When
> I set the canvas to this side, the window goes wonky. I figured I
> could put the canvas into a frame and limit the frame size and add
> scrolling.
>
> But the scrollbars are always greyed out, even though I can move
> canvas items off the edges.
>
> Also, I'd like to be able to resize the window (without resizing the
> items on the canvas) so that more or less canvas is exposed and have
> the scrollbars automatically adjust.
>
> I see all kinds of wrappers and custom code to do this, but doesn't Tk
> support this natively? I find a lot of stuff on Tcl.Tk that does
> things that Tk does by itself it seems already.
>
Did you

$canvas configure -scrollregion

appropriately? That's the step I always forget :-)

Alan
From: Bruce Hartweg on
ccie15672 wrote:
> All:
>
> I've read a number of messages here on the group and I've been all
> over tcl.tk and I've looked at several books... and I guess there is
> something I'm missing... hopefully something obvious.
>
> I need a very large canvas. Only a portion of which will be visible.
> As I understand it, the canvas can be up to 32000x32000 pixels. When
> I set the canvas to this side, the window goes wonky. I figured I
> could put the canvas into a frame and limit the frame size and add
> scrolling.

DO NOT SET THE SIZE OF THE CANVS THAT BIG

the canvas widget is what is being shown on the display - it doesn't
have to cover the entire size of the object within it.
You shouldn't directly set the size, just pack/grid it and let
the geometry manager handle things

to make the "virutal" size big enough you set the scroll region
to tht size and *that* is what makes the scrollbars work

you can set the scrollregion to a fixed big size, or use the
[$canvas bbox all] command and set it to the size needed by
the current contents (and update this if you change the contents)

Bruce
From: Arjen Markus on
On 4 mrt, 01:45, Bruce Hartweg <doNOTmai...(a)example.com> wrote:
> ccie15672 wrote:
> > All:
>
> > I've read a number of messages here on the group and I've been all
> > over tcl.tk and I've looked at several books... and I guess there is
> > something I'm missing... hopefully something obvious.
>
> > I need a very large canvas.  Only a portion of which will be visible.
> > As I understand it, the canvas can be up to 32000x32000 pixels.  When
> > I set the canvas to this side, the window goes wonky.  I figured I
> > could put the canvas into a frame and limit the frame size and add
> > scrolling.
>
> DO NOT SET THE SIZE OF THE CANVS THAT BIG
>
> the canvas widget is what is being shown on the display - it doesn't
> have to cover the entire size of the object within it.
> You shouldn't directly set the size, just pack/grid it and let
> the geometry manager handle things
>
> to make the "virutal" size big enough you set the scroll region
> to tht size and *that* is what makes the scrollbars work
>
> you can set the scrollregion to a fixed big size, or use the
> [$canvas bbox all] command and set it to the size needed by
> the current contents (and update this if you change the contents)
>
> Bruce

Yes, here is a small example:

scrollbar .y -command {.c yview} -orient vertical
scrollbar .x -command {.c xview} -orient horizontal
canvas .c -yscrollcommand {.y set} -xscrollcommand {.x set}
grid .c .y -sticky news
grid .x -sticky news

..c configure -scrollregion {-1000 -1000 1000 1000}
..c create oval 0 0 200 200 -fill red -outline black -width 3

Regards,

Arjen
From: ccie15672 on
Thanks for the responses. I figured it out with a few hours of
hackery. I was suffering from a great deal of ignorance re: Tk.