Hello Perl Monks

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(); }

In reply to Question about how to implement user control over text box height by CrashBlossom

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.