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

In reply to Re: map two text widgets using Tk? by zentara
in thread map two text widgets using Tk? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.