Hi.

I've put together three listboxes with a common vertical scrollbar to the right of the third listbox using the TK library. I put an adjuster on the first and second listboxes. The issue I am having is that when either of the adjusters is used to stretch its listbox to the right then the widgets to the right of the adjuster slide off to the right out of view and are not displayed in the main window. Then when the adjuster is moved to the left to shrink the listbox then the widgets slide back into view in the main window. Do you know of a way to keep all of the widgets visible in the main window in this scenario, especially the vertical scrollbar such that it always stays "anchored" near the right edge of the main window.

I saw another post about keeping the size of widgets with adjusters in proportion to the size of the main window as the size of the main window changes but I am not sure if all of that is necessary to accomplish what I'm looking to do.

Thanks very much in advance. Tim

use Tk; use Tk::Adjuster; $mw = MainWindow->new(-title => "My Adjuster Example"); $mw->resizable( 0, 0 ); # not resizable in any direction $listboxesFrame = $mw->Frame(); $mfLbScrollBar = $listboxesFrame->Scrollbar(-orient=>'v'); $mfItemNameLb = $listboxesFrame->Listbox(-height => 25); $adj1 = $listboxesFrame->Adjuster(); $mfItemCurrentBubbleLb = $listboxesFrame->Listbox(-height => 25); $adj2 = $listboxesFrame->Adjuster(); $mfItemOtherBubbleLb = $listboxesFrame->Listbox(-height => 25); # Array of the three Listboxes $mfListBoxes = [ $mfItemNameLb, $mfItemCurrentBubbleLb, $mfItemOtherBu +bbleLb ]; # Configure each Listbox to call &scroll_listboxes foreach $list (@$mfListBoxes) { $list->configure(-yscrollcommand => [ \&scroll_listboxes, $mfLbScrol +lBar, $list, $mfListBoxes ]); } # Configure the Scrollbar to scroll each Listbox $mfLbScrollBar->configure(-command => sub { foreach $list (@$mfListBox +es) { $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->grid(-row=>1,-column=>1, -padx => 10, -pady => 10); MainLoop; 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 } }


In reply to Tk::Adjuster causes widgets to slide out of the main window out of view 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.