Hello Monks,

I am having an issue re-packing an adjuster frame in between two other widgets. The left widget is a listbox, displaying database search results. The right widget is an ROtext, displaying detailed information about the list on the left. In between them is an Adjuster, which allows the user to adjust how much of each widget is "in view". This works fine.

My issue is that I have a special search case, which does not contain detailed data and thus does not require the adjuster or the ROtext. So I "packForget" those widgets and just display the listbox. When the user returns to the "normal" search type, I "re-pack" the adjuster and ROtext. However, the adjuster always seems to encroach into the ROtext frame. Or, maybe more accurately, pulls away from the listbox.

You can demonstrate this behavior by running my code, and switching between the two search types. When the GUI is first constructed, everything looks fine. Then when you switch to the "list only", and back to "list and data", the adjuster has moved! I cannot figure out where my pack error lies. I just want the adjuster to come back in the same place as it was originally! Please help, and thanks!!

#!/apps/perl/bin/perl use strict; use warnings; use Tk; use Tk::Adjuster; use Tk::ROText; my $mw = MainWindow->new(-width=>1500,-height=>650); $mw->packPropagate(0); my $topFrame = $mw->Frame(-relief => 'groove', -borderwidth => 2)-> pack(-side => 'top', -anchor => 'n', -fill => 'x'); my $searchFrame = $topFrame->Frame()-> pack(-side => 'left', -anchor => 'w', -padx => 8, -pady => 3); my $list = $mw->Scrolled("Listbox", -scrollbars => 'se', -selectmode => 'single')-> pack(-side => 'left', -padx => 3, -expand => 1, -fill => 'both', -a +nchor => 'w'); my $RO_text = $mw->Scrolled("ROText", -scrollbars => 'se', -wrap => 'word')-> pack(-side => 'left', -anchor => 'w', -fill => 'both', -expand => 1 +); my $adjuster = $mw->Adjuster()->packAfter($list, -side => 'left'); my $searchType; my @searchOptions = ( 'list_and_data', 'list_only' ); $topFrame->Optionmenu( -variable => \$searchType, -options => \@searchOptions, -command => [ \&changeSearchType, \$searchFrame +, \$list] )-> pack(-side => 'right', -anchor => 'w', -padx => 5, ipadx => 3); $topFrame->Label(-text => 'Search Type:')->pack(-side => 'right', -anc +hor => 'w'); MainLoop; sub changeSearchType { if( $searchType eq 'list_only' ) { $RO_text->packForget; $adjuster->packForget; $list->pack(-side => 'left', -expand => 1, -fill => 'both', -anc +hor => 'w'); my @results = ("apple","banana","orange"); $list->delete(0,'end'); $list->insert('end',\@results); } else { $adjuster->packAfter($list, -side => 'left'); $RO_text->pack(-side => 'left', -expand => 1, -fill => 'both', - +anchor => 'w'); my @results = ("apple","banana","orange"); $list->delete(0,'end'); $list->insert('end',\@results); $RO_text->delete('1.0','end'); $RO_text->insert('end',"These are examples of fruit"); } } 1;

In reply to Issue packing a Tk::Adjuster by jbuck

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.