in reply to Tk: Does the 'grid' geometry manager has a problem with a scrolled parent?

It gets messy when you mix grid with pack, I usually just stick with pack. Anyways, when you just use
$graph_pane = $mw->Frame(
the frame expands to encompass everything it contains.

When you use the Scrolled('Frame it sets it's scrollbars to a small size because nothing is in it yet. If you tell it to use a specific size, is one workaround. Like:

$mw->geometry('1000x200'); MainLoop;

However, I question why you want to use 6 Canvas objects, when using one would be more efficient. Additionally, if you use one scrolled Canvas, you can use the -scrollregion along with canvas height and width to adjust what you see and can scroll.


I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
Re^2: Tk: Does the 'grid' geometry manager has a problem with a scrolled parent?
by tcarmeli (Beadle) on Aug 07, 2006 at 15:19 UTC
    Hi,
    Thanks for the tips.
    This was just an example. In my application each canvas is some graph, scrollable on it own. The main reason I wanted to get the rows and columns in the first place was to set the size of the window since the number of rows and columns depends on the user's choices.
    Cheers
      I would make a main Scrolled Pane. Then in that Scrolled Pane, place your Scrolled Canvases in a series of stacked frames. You can use packForget to repack them according to user choice.
      #!/usr/bin/perl use strict; use Tk; use Tk::Pane; my $mw = MainWindow->new; $mw->geometry('400x250'); my $mwf = $mw->Scrolled('Pane', -scrollbars=>'osoe', -sticky=>'nwse', )->pack(-expand=>1, -fill=>'both'); my $f1 = $mwf->Frame()->pack(); my $f2 = $mwf->Frame()->pack(); my %canv; for (0..4){ $canv{$_}{'obj'} = $f1->Scrolled('Canvas', -height => 100, -width => 100, -bg =>'white', -scrollbars => 'osoe', -scrollregion => [ 0, 0, 500, 500 ], )->pack(-side =>'left' ,-padx=>10,-pady=>10); $canv{$_}{'obj'}->createText(50,50, -text => $_, -anchor => 'center', ); } for (5..9){ $canv{$_}{'obj'} = $f2->Scrolled('Canvas', -height => 100, -width => 100, -bg =>'white', -scrollbars => 'osoe', -scrollregion => [ 0, 0, 500, 500 ], )->pack(-side =>'left', -padx=>10,-pady=>10 ); $canv{$_}{'obj'}->createText(50,50, -text => $_, -anchor => 'center', ); } MainLoop();

      I'm not really a human, but I play one on earth. Cogito ergo sum a bum