I have a question about how to provide a way for the user to control the height (in number of lines) of a text box
I am running strawberry perl 5.24 under windows 7.
My main window has an expandable list box on top and a fixed height text box on bottom. So if the user uses the mouse to grow the main window, the height of the list box on top increases, but the height of the text box on the bottom stays the same. See the code below for the details.
What I would like to do is make controls to allow the user to adjust the height of the text box, preferably without affecting the contents of either the list box or the text box. So if the user expands the main window, the height of the text box will still remain fixed at the value set by the user.
In the code below, I tried to use the configure method to change the height, but it had no effect. Any suggestions or advice would be appreciated.
use strict; use warnings; use Cwd; use Tk qw( MainLoop ); require Tk::ROText; { my $startb; my $textbox; my $mw = MainWindow->new(-background => 'gray50' ); my $listbox = $mw->Scrolled('Listbox', -font => "{Courier New} 12 bold", -background => 'DarkCyan', -foreground => 'OldLace', -scrollbars => 'se', -selectmode => "single", )->pack(-expand => 1, -fill => 'both'); $textbox = $mw->Scrolled('ROText', -font => "{Courier New} 12 bold", -background => 'DarkBlue', -foreground => 'OldLace', -scrollbars => 'se', -wrap => 'none', -height => 8 )->pack(-expand => 0, -fill => 'x', -anchor => 'n'); my $buttonFrame = $mw->Frame()->pack(-side => 'bottom', -fill=>'both +', -expand=>0); # Button to increase the height of the text box my $growb = $buttonFrame->Button( -text => '+', -command => sub { $textbox->packForget; $textbox->configure(-height => 11); $textbox->pack(-expand => 0, -fill => 'x +', -anchor => 'n'); $textbox->configure(-background => 'red1'); $mw->idletasks; }, )->pack(-side => "left", -fill => "b +oth", -expand => 0); # Button to decrease height of text box my $shrinkb = $buttonFrame->Button( -text => '-', -command => sub { $textbox->packForget; $textbox->configure(-height => 6); $textbox->pack(-expand => 0, -fill => 'x', + -anchor => 'n'); $textbox->configure(-background => 'DarkBl +ue'); $mw->idletasks; }, )->pack(-side => "left", -fill = +> "both", -expand => 0); MainLoop(); }
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |