in reply to Window scrollbar

Make a Scrolled Pane. Into the Scrolled Pane, pack a Frame for each row. To each Frame, add your Text widgets, packing left to right. Here is the idea with a bunch of Scrolled Canvases. If you also need to control focus, it is shown too. Of course, for 100 rows, you will need to automate the loop, I just hardwired in 2 Frames. UPDATE: added -expand=>1,-fill=>'both' options to make resizing look nice.
#!/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(-expand=>1,-fill=>'both'); my $f2 = $mwf->Frame()->pack(-expand=>1,-fill=>'both'); 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,-expand=>1,-fill=>'both +'); $canv{$_}{'obj'}->createText(50,50, -text => $_, -anchor => 'center', ); my $num = $_; $canv{$num}{'obj'}->CanvasBind( '<FocusOut>' => sub{ $canv{$num}{'obj'}->configure(-bg=>'lightyellow'); } ); $canv{$num}{'obj'}->CanvasBind( '<FocusIn>' => sub{ $canv{$num}{'obj'}->configure(-bg=>'lightgreen'); } ); } 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 ,-expand=>1,-fill=>'bot +h'); $canv{$_}{'obj'}->createText(50,50, -text => $_, -anchor => 'center', ); my $num = $_; $canv{$num}{'obj'}->CanvasBind( '<FocusOut>' => sub{ $canv{$num}{'obj'}->configure(-bg=>'lightyellow'); } ); $canv{$num}{'obj'}->CanvasBind( '<FocusIn>' => sub{ $canv{$num}{'obj'}->configure(-bg=>'lightgreen'); } ); } my $button = $mw->Button(-text=>'Focus 1', -command => sub{ $canv{1}{'obj'}->focusForce; $canv{1}{'obj'}->configure(-bg=>'blue'); })->pack(); MainLoop();

I'm not really a human, but I play one on earth Remember How Lucky You Are

Replies are listed 'Best First'.
Re^2: Window scrollbar
by Aboveyou (Acolyte) on Feb 02, 2009 at 20:22 UTC
    I want it to look like the follow example main windows and row of 5 widgets just add scrollbar that can go up and down
    #!/usr/bin/perl use strict; use Tk; use Tk::Pane; my $mw = MainWindow->new; $mw->geometry('400x250'); my $mwf = $mw->Scrolled('Pane', -scrollbars=>'ose', -sticky=>'nwse', )->pack(-expand=>1, -fill=>'both'); my $f1 = $mwf->Frame()->pack(); my $f2 = $mwf->Frame()->pack(); my $textTopStart = 328; my $textTop = $textTopStart; my $textHeight = 31; my @textWidth = ("4", "160", "309", "460", "609"); my $dude2 = $mw->Text(-background => 'white', -foreground => 'black' +,-height => 1,-width => 22)->place( -x => $textWidth [0], -y => $textTop); my $dude3 = $mw->Text(-background => 'white', -foreground => 'blac +k',-height => 1,-width => 21)->place( -x => $textWidth[1], -y => $textTop); my $dude4 = $mw->Text(-background => 'white', -foreground => 'blac +k',-height => 1,-width => 21)->place( -x => $textWidth[2], -y => $textTop); my $dude5 = $mw->Text(-background => 'white', -foreground => 'blac +k',-height => 1,-width => 21)->place( -x => $textWidth[3], -y => $textTop); my $dude6 = $mw->Text(-background => 'white', -foreground => 'blac +k',-height => 1,-width => 22)->place( -x => $textWidth[4], -y => $textTop); $textTop += $textHeight; MainLoop();