A program is worth a million words. :-)

Here is a simple example. For very complex layouts, you can even have subframes within each horizontal frame. For instance when you want very hard to obtain alignments. Here are 2 examples which show the ropes.

#!/usr/bin/perl use strict; use Tk; use Tk::Pane; my $mw = MainWindow->new; $mw->geometry( '1000x600' ); my $mwf = $mw->Scrolled( 'Pane', -scrollbars => 'ose', -sticky => 'nwse', )->pack( -expand => 1, -fill => 'both' ); # make some frames to contain items on same line my $f1 = $mwf->Frame()->pack( -expand => 1, -fill => 'both' ); my $f2 = $mwf->Frame()->pack( -expand => 1, -fill => 'both' ); my $f3 = $mwf->Frame()->pack( -expand => 1, -fill => 'both' ); my $f4 = $mwf->Frame()->pack( -expand => 1, -fill => 'both' ); my $f5 = $mwf->Frame()->pack( -expand => 1, -fill => 'both' ); # ---------------------------------- # | 400x500 (write only) text area | # ---------------------------------- # Label1: drop down # (user's input echo'd from Label1) # Label2: drop down # (user's input echo'd from Label2) # Select Directory # (Text are with user's input dir echo'd) # Label3: drop down # (User's input echo'd from Label3) my $text1 = $f1->Text(-bg => 'white')->pack(-side => 'left'); my $label1 = $f2->Label(-bg => 'lightseagreen', -text => 'left') ->pack( -side => 'left'); my $label2 = $f2->Label(-bg => 'lightyellow', -text => 'right') ->pack( -side => 'right'); my $text2 = $f3->Text(-bg => 'black')->pack(-side => 'right'); my $label3 = $f4->Label(-bg => 'hotpink', -text => 'bottom') ->pack(); MainLoop();
and Label alignment
#!/usr/bin/perl use Tk; use strict; use warnings; my $mw = MainWindow->new( -bg => 'beige', ); my $l = $mw->Frame( -width => 111, -height => 333, -relief => "raised", -borderwidth => 2, -bg => '#EEE000', )->pack( -fill => 'x', -side => 'left', -anchor => 'n', ); my $r = $mw->Frame( -width => 111, -height => 333, -relief => "raised", -borderwidth => 2, -bg => '#F0F000', )->pack( -fill => 'both', -side => 'left', -anchor => 'n', ); my $r2 = $mw->Frame( -width => 111, -height => 333, -relief => "raised", -borderwidth => 2, -bg => '#F0F000', )->pack( -fill => 'both', -side => 'left', -anchor => 'n', ); for ( qw[Name: Version: Description: Date: ] ){ $l->Label( -text => $_, -justify => 'left', -anchor => 'w', )->pack( #-anchor => 'e', # if you don't fill -fill => 'x', ); $r->Label( -text => $_, # -justify => 'right', -anchor => 'e', )->pack( -anchor => 'e', # if you don't fill #-fill => 'x', ); $r2->Label( -text => $_, -justify => 'right', # -anchor => 'e', )->pack( #-anchor => 'e', # if you don't fill #-fill => 'x', ); } #$top->Label(-text => "Enter the scroll frame")->pack; MainLoop;

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re^3: tk positioning of widgets by zentara
in thread tk positioning of widgets by gibsonca

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.