First use warnings and use strict.
Second this is kind of complex to answer, because Scrolled widgets do some internal magical linking, so trying to orchestrate them all together, and still allow them to work independently, is intricate.(More than I care to sweat over this afternoon :-)) You may be better off building ALL your widgets with manual scrollbars, then somehow juggling everything.
But here is a start with a ScrolledPane. The only glitch is that the master scrollbar only works when you hit the up or down arrow graphics (which move things 1 unit in that direction). If you try to drag the green bar, everything resets to the master yview.
If it was me, I would ditch the master scrollbar,and make custom labels with up/down arrows to replace the master scrollbar, and just have them do a + or - 1 unit increment, instead of the yview(@_). In other words, use a Pane, instead of the ScrolledPane, and pack a frame on the left, with an up and down label. Link each label's mouse 1 click to scroll 1 unit in all Scrolled Listboxes.
But if you are persistent and clever, you may be able to setup a yscrollcommand that dosn't reset all listboxes to the @_ of the yscrollbar, but it's up to you, or someone else may know the trick.
#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Pane; my $mw = MainWindow->new(); $mw->geometry("600x300+100+100"); $mw->Button( -text => "Exit", -command => sub { exit } )->pack( -side => 'bottom', -fill => 'x' ); my $parent = $mw->Scrolled('Pane' ) ->pack( -fill => 'both', -expand => 1 ); my $yscroll = $parent->Subwidget('yscrollbar'); my @listboxes; foreach my $num (1..4) { my $list = $parent->Scrolled('Listbox'); foreach my $num (1..100){ $list->insert( 'end', $num); } $list->pack( -side => 'left', -fill => 'y', -expand => 1 ); push @listboxes, $list; } $yscroll->configure( -background => "lightgreen", -troughcolor => "black", -command => sub { foreach my $list (@listboxes) { $list->yview(@_); # $list->yviewScroll(1,'units'); } }, ); MainLoop;
In reply to Re: How to Scroll multiple Frames using Tk::Pane
by zentara
in thread How to Scroll multiple Frames using Tk::Pane
by ravishi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |