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

ok first, this is my first perl/tk project second, i have searched and searched for this and cant find anything ok i am trying to create a window with multiple frames that fill the window both x and y (no prob so far, i can do with with pack) however, i would like to make the width and/or height a percent of the total size of the window so they arent all the same size. can i accomplish this with pack or is there another geometry manager i should use? thanks
c0s

Replies are listed 'Best First'.
Re: tk frames with percent widths
by zentara (Cardinal) on Jan 15, 2004 at 16:27 UTC
    Here is an example of an "not often seen" option.
    #!/usr/bin/perl use Tk; my $mw=tkinit; my $frame = $mw->Frame(-bg=>'black'); $frame->place(-in=>$mw, -x=>0, -y=>0, -relheight=>0.5,-relwidth=>0.5); MainLoop; __END__
Re: tk frames with percent widths
by rinceWind (Monsignor) on Jan 15, 2004 at 16:49 UTC
    Although zentara's solution of using place may work, much depends on how complex and intricate your application will become. The disadvantage of place is that it does very little of the calculation and automatic allocation that the other geometry managers do. Granted, relative x and y do what you want here.

    Perhaps you should consider using grid, if your application is laid out in rows and columns like an Excel spreadsheet or a HTML table. In this case, setting gridColumnconfigure($_, -weight => 1) for all columns and gridRowconfigure($_, -weight => 1) for all rows, will give you a grid which will give proportionally equal space, and resize properly when you resize the parent window. For an example of this, have a look at the RPN calculator example here.

    For more sophisticated layouts with percentage allocation, look at form, though I have never had need to use it.

    Hope this helps

    --
    I'm Not Just Another Perl Hacker