Here is a simplified example which ought to show you the basic idea. Doing tricks with scrollbars can get involved, so its best for you to jump in there and play with them.
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::Scrollbar;
use Tk::Text;
my $mw = Tk::MainWindow->new();
my $f1 = $mw->Frame()->pack(-side => 'top');
my $f2 = $mw->Frame()->pack(-side => 'left');
my $f3 = $mw->Frame()->pack(-side => 'bottom');
my $text1= $f1->Text( )->pack(
-expand => 1,
-fill => 'both',
);
my $text2 = $f3->Text( )->pack(
-expand => 1,
-fill => 'both',
);
# vertical scroll bar for both text windows
my $yscroll = $f2->Scrollbar()->pack(
-fill => 'y',
-expand => 1,
-side => 'right',
);
$yscroll->configure( -command => [ \&scroll_both, $yscroll, [$text1,$t
+ext2]]);
$text1 ->configure( -yscrollcommand => [ \&set_yscroll ]);
$text2 ->configure( -yscrollcommand => [ \&set_yscroll ]);
&fill($text1);
&fill($text2);
MainLoop();
#------------------------------------------------------
sub fill{
my $widget = shift;
for (1..300){
$widget->insert('end',"$_\n");
}
$widget ->see('1.0');
$widget->idletasks;
}
#-------------------------------------------------------
sub set_yscroll {
# This handles updating yscroll, and making sure both the text
# boxes are sync'ed when one of them scrolls via the cursor keys
$yscroll->set(@_);
foreach my $w ($text1, $text2) {
$w->yviewMoveto($_[0]);
}
}
#--------------------------------------------------------
sub scroll_both {
my ($sb,$wigs,@args) = @_;
my $w;
foreach $w (@$wigs) {
$w->yview(@args);
}
}
#---------------------------------------------------------
I'm not really a human, but I play one on earth.
flash japh
|