jbuck has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Issue packing a Tk::Adjuster
by beech (Parson) on Apr 19, 2016 at 01:58 UTC | |
|
Re: Issue packing a Tk::Adjuster
by Marshall (Canon) on Apr 18, 2016 at 23:06 UTC | |
|
Re: Issue packing a Tk::Adjuster
by Anonymous Monk on Apr 19, 2016 at 01:16 UTC | |
|
Re: Issue packing a Tk::Adjuster
by Anonymous Monk on Jul 10, 2019 at 05:36 UTC |