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

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
  • Comment on Re^2: Tk: Does the 'grid' geometry manager has a problem with a scrolled parent?

Replies are listed 'Best First'.
Re^3: Tk: Does the 'grid' geometry manager has a problem with a scrolled parent?
by zentara (Cardinal) on Aug 07, 2006 at 16:49 UTC
    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