vikee has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I have a Scrolled (Pane) and a frame (can be changed).
I need something that joins the horizontal scrolling. 
When I scroll the Pane I need the frame to scroll too,
and vice-versa.
$f_header = $top->Frame()->pack( side => 'top', -anchor => 'nw' ); $sp_list = $top->Scrolled( 'Pane', -relief => 'flat', -height => 127, -scrollbars => 'se' )->pack( -expand => 1, -fill => 'both', side => 'top', -pady => 4 );

Replies are listed 'Best First'.
Re: Tk: joined scroll
by zentara (Cardinal) on Jul 22, 2004 at 13:51 UTC
    I'm not sure what you want to do, a Frame can't be scrolled, but the Pane can. You can connect scrollbars with the xscrollcommand or yscrollcommand. Here is an example for connecting the yscroll for a bunch of listboxes. You can try a similar techique for your widgets.
    #!/usr/bin/perl use warnings; use strict; use Tk; my $list; my $parent; my $mw = MainWindow->new(); $mw->title("Listbox"); $mw->geometry("600x300+100+100"); $mw->Button( -text => "Exit", -command => sub { exit } )->pack( -side => 'bottom', -fill => 'x' ); $parent = $mw->Listbox()->pack( -side => 'left', -fill => 'y', -expand + => 1 ); my $yscroll = $parent->Scrollbar(-orient => 'vertical'); my $listboxes = [ $parent->Listbox(), $parent->Listbox(), $parent->Listbox(), $parent->Listbox(), ]; foreach $list (@$listboxes) { $list->configure( -yscrollcommand => [ \&scroll_listboxes, $yscroll, $list, $li +stboxes ], ); } $yscroll->configure( -command => sub { foreach $list (@$listboxes) { $list->yview(@_); } } ); $yscroll->pack( -side => 'left', -fill => 'y' ); my $count = 0; foreach $list (@$listboxes) { $list->insert( 'end', "one-$count", "two-$count", "three-$coun +t", "four-$count", "five-$count", "six-$count", "seve +n-$count", "eight-$count", "nine-$count", "ten-$count", "elev +en-$count", "twelve-$count", "thirteen-$count", "fourteen-$count", "fift +een-$count", "sixteen-$count", "seventeen-$count", "eighteen-$count", "nine +teen-$count", "twenty-$count" ); $count++; $list->pack( -side => 'left', -fill => 'y', -expand => 1 ); } MainLoop; sub scroll_listboxes { my ( $sb, $scrolled, $lbs, @args ) = @_; $sb->set(@args); my ( $top, $bottom ) = $scrolled->yview(); foreach $list (@$lbs) { $list->yviewMoveto($top); } } ##############################################################

    I'm not really a human, but I play one on earth. flash japh
      Hello, I need something like this:
      +--------------+
      |  header      |
      +--------------+
      +  data        +
      +              +
      +--------------+
      

      the data can be scrolled vertically, there are many rows.
      if the line is too long than i need to scroll them
      horizontally, and i need to join the horizontal scrolling
      of the header and the datas.
        Maybe you should use Tk::HList? The second demo in the "widget" program has a header and vertical and horizontal scrollbars, so you can take a look there for an example.