I have a program in which I am trying to create a scrollbar that can scroll multiple frames. Each frame has its own scrollbar using Tk::Pane. I have found code online which provides a solution if I was using Listboxes but not for Frames. Below is my code:

#!/usr/bin/perl # Multiple Widgets with one scrollbar.pl use Tk; require Tk::Pane; $mw = MainWindow->new(); $mw->title("One Scrollbar/Three Listboxes"); $mw->Button(-text => "Exit", -command => sub { exit })->pack(-side => 'bottom'); $scroll =$mw->Scrollbar(); # Anonymous array of the three Listboxes $listboxes = [ $mw->Scrolled(Pane, -scrollbars => 'ose', -sticky => 'nsew', -background => 'green') +, $mw->Scrolled(Pane, -scrollbars => 'ose', -sticky => 'nsew', -background => 'blue'), $mw->Scrolled(Pane, -scrollbars => 'ose', -sticky => 'nsew', -background => 'cyan') +]; # This method is called when on Listbox is scrolled with the keyboard # It makes the Scrollbar reflect the chang, and scrolls the other list +s sub scroll_listboxes { my ($sb, $scrolled, $lbs, @args) = @_; $sb->set(@args); # tell the Scrollbar what to display my ($top, $bottom) = $scrolled->yview(); foreach $list (@$lbs) { $list->yviewMoveto($top); # adjust each lb } } # Configure each Listbox to call &scroll_listboxes foreach $list (@$listboxes) { $list->configure(-yscrollcommand => [ \&scroll_listboxes, $scroll, $list, $listboxes ] ); } # Configure the Scrollbar to scroll each Listbox $scroll->configure(-command =>sub { foreach $list (@$listboxes) { $list->yview(@_); }}); # Pack the Scrollbar and Listboxes $index = 0; $scroll->pack(-side => 'left', -fill => 'y'); foreach $list (@$listboxes) { $list->pack(-side => 'left'); $list->Label(-text => "One")->pack(); $list->Label(-text => "Two")->pack(); $list->Label(-text => "Three")->pack(); $list->Label(-text => "Four")->pack(); $list->Label(-text => "Five")->pack(); $list->Label(-text => "Six")->pack(); $list->Label(-text => "Seven")->pack(); $list->Label(-text => "Eight")->pack(); $list->Button(-text => "$index", -command => sub { exit})->pac +k(); $index++; } MainLoop;

When I run it, it displays my three Frames with their own individual scrollbars. But when I try to control the main scrollbar, it gives me this error:
Tk::Error: Can't call method "rooty" without a package or object reference at /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Tk +/ Pane.pm line 256. Tk::Pane::yview at /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread- multi/Tk/Pane.pm line 256 Tk::Derived::Delegate at /usr/lib/perl5/site_perl/5.8.8/i386-linux- thread-multi/Tk/Derived.pm line 469 Tk::Widget::__ANON__ at /usr/lib/perl5/site_perl/5.8.8/i386-linux- thread-multi/Tk/Widget.pm line 322 main::__ANON__ at ./multiScroll2.pl line 49 Tk::Scrollbar::ScrlByPages at ../blib/lib/Tk/Scrollbar.pm (autosplit into ../blib/lib/auto/Tk/Scrollbar/ScrlByPages.al) line 372 Tk::Scrollbar::Select at ../blib/lib/Tk/Scrollbar.pm (autosplit into ../blib/lib/auto/Tk/Scrollbar/Select.al) line 201 Tk::Scrollbar::ButtonDown at ../blib/lib/Tk/Scrollbar.pm (autosplit into ../blib/lib/auto/Tk/Scrollbar/ButtonDown.al) line 159 <Button-1> (command bound to event)
This is my first post so be easy on me. Thanks!

In reply to How to Scroll multiple Frames using Tk::Pane by ravishi

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.