minixman has asked for the wisdom of the Perl Monks concerning the following question:

All How do i assign a box in a window
that will auto size the width to the parent windows.
my $botfrm = $MW->Frame->pack(-fill => 'x', -expand => 1); my $txt = $botfrm -> Scrolled('Text',-width=>57,-height=>5,-scrollbars + =>'o') -> pack ();

2005-11-03 Retitled by g0n, as per Monastery guidelines
Original title: 'TK Scrolled box'

Replies are listed 'Best First'.
Re: auto sizing TK Scrolled box
by thundergnat (Deacon) on Nov 03, 2005 at 12:10 UTC

    If you want to use the pack geometry manager, you need to pack both the widget and it's container (if it isn't a top level) with -expand => 'true' (for any value of true) and -fill => 'both'.

    use warnings; use strict; use Tk; my $mw = Mainwindow->new; my $frame = $mw->Frame->pack(-expand => 1, -fill => 'both'); my $text = $frame->Scrolled('Text', -scrollbars => 'se', )->pack(-expand => 1, -fill => 'both'); MainLoop;
Re: auto sizing TK Scrolled box
by GrandFather (Saint) on Nov 03, 2005 at 11:46 UTC

    I tend to use the form geometery manager as it provides a good deal more control when resizing. Try the following code:

    use strict; use warnings; use Tk; my $main = MainWindow->new (-title => "Demo"); my $txt = $main -> Scrolled('Text',-width=>57,-height=>5,-scrollbars = +>'osoe'); $txt->form (-left=>'%0',-top=>'%0',-bottom=>'%100',-right=>'%100'); $txt->Insert ("text\n\n\nMore\n\n\nand more"); MainLoop ();

    Perl is Huffman encoded by design.