Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Tk::Adjuster causes widgets to slide out of the main window out of view

by lamprecht (Friar)
on Jan 07, 2011 at 15:57 UTC ( [id://881099]=note: print w/replies, xml ) Need Help??


in reply to Tk::Adjuster causes widgets to slide out of the main window out of view

Hi Tim,

keep the scrollbar outside of the frame that holds the adjusted widgets:

#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Adjuster; my $mw = MainWindow->new(-title => "My Adjuster Example"); $mw->resizable( 0, 0 ); # not resizable in any direction my $listboxesFrame = $mw->Frame(); my $mfLbScrollBar = $mw->Scrollbar(-orient=>'v'); my $mfItemNameLb = $listboxesFrame->Listbox(-height => 25); my $adj1 = $listboxesFrame->Adjuster(); my $mfItemCurrentBubbleLb = $listboxesFrame->Listbox(-height => 25); my $adj2 = $listboxesFrame->Adjuster(); my $mfItemOtherBubbleLb = $listboxesFrame->Listbox(-height => 25); # Array of the three Listboxes my $mfListBoxes = [ $mfItemNameLb, $mfItemCurrentBubbleLb, $mfItemOthe +rBubbleLb ]; # Configure each Listbox to call &scroll_listboxes foreach my $list (@$mfListBoxes) { $list->configure(-yscrollcommand => [ \&scroll_listboxes, $mfLbScrol +lBar, $list, $mfListBoxes ]); } # Configure the Scrollbar to scroll each Listbox $mfLbScrollBar->configure(-command => sub { foreach my $list (@$mfList +Boxes) { $list->yview(@_); }}); $mfItemNameLb->pack(-side => 'left', -expand => 1, -fill => 'both'); $adj1->packAfter($mfItemNameLb, -side => 'left'); $mfItemCurrentBubbleLb->pack(-side => 'left', -expand => 1, -fill => ' +both'); $adj2->packAfter($mfItemCurrentBubbleLb, -side => 'left'); $mfItemOtherBubbleLb->pack(-side => 'left', -expand => 1, -fill => 'bo +th'); $mfLbScrollBar->pack(-side => 'right', -fill => 'y'); $listboxesFrame->pack(-side => 'left', -fill => 'y'); MainLoop; sub scroll_listboxes { my ($sb, $scrolled, $lbs, @args) = @_; $sb->set(@args); # tell the Scrollbar what to display my ($top, $bottom) = $scrolled->yview( ); foreach my $list (@$lbs) { $list->yviewMoveto($top); # adjust each lb } }

Cheers, Chris
  • Comment on Re: Tk::Adjuster causes widgets to slide out of the main window out of view
  • Download Code

Replies are listed 'Best First'.
Re^2: Tk::Adjuster causes widgets to slide out of the main window out of view
by Anonymous Monk on Jan 07, 2011 at 16:16 UTC

    Chris, that change made it work exactly how I wanted it to work. Thanks for the timely help!!!

    Tim

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://881099]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2026-04-12 22:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.