'lo everyone...

I'm fairly new to using Perl/Tk, although I've been using perl for quite a few years.

I would like to build a series of prompt labels and entry fields on a single window in a format like:

       Name: ____________________
    Version: __________
    Description: ________________________________________
         Date: __________

(I want the colons to line-up vertically and the whole thing to be centred in the window).

The code is included at the bottom of this post.

The use of pack() seems to be non-intuitive to me, once you get more than one widget in a frame.

If someone could explain what I'm doing wrong, I'd be very appreciative.

I'm using ActiveState Perl v5.6.1, build 628, Perl/Tk version 800.022 on Windows 98 SE (OEM).

Many thanks for any forthcoming suggestions.

John

use strict; use Tk; my $mw = MainWindow->new; # Main window $mw->geometry('532x432+100+200'); $mw->resizable(0, 0); # ...no re-sizing # ------------------------------------- # Create frames for widgets # my $hdrfrm = $mw->Frame( # The Top 'Bar' -background => 'magenta', -height => 10, )->pack(-side => 'top', -fill => 'x'); # , -pady => 5); my $entryfrm = $mw->Frame( # The Middle 'Bar' -background => 'cyan', -width => 200, -height => 200, )->pack(-side => 'top', -fill => 'x'); my $btnfrm = $mw->Frame( # The Button 'Bar' -background => 'darkgrey', # -height => 30, )->pack(-side => 'top', -fill => 'x'); # , -pady => 5); # ------------------------------------- # Place buttons # my $AddBtn = $btnfrm->Button( # 'Add' -text => ' Add ', -command => [$mw => 'destroy'] )->pack(-side => 'left', -padx => 10, -pady => 5); my $RptBtn = $btnfrm->Button( -text => 'Report', -command => [$mw => 'destroy'] )->pack(-side => 'left', -padx => 5, -pady => 5); my $AboutBtn = $btnfrm->Button( -text => 'About', -command => [$mw => 'destroy'] )->pack(-side => 'left', -padx => 100); my $DoneBtn = $btnfrm->Button( -text => ' Done ', -command => [$mw => 'destroy'] )->pack(-side => 'right', -padx => 10, -pady => 5); # ------------------------------------- # Place prompt labels and fields # my $pmt2 = $entryfrm->Label( # Name -text => 'Name:', -background => 'magenta', )->pack(-side => 'left'); # , -anchor => 'n'); my $fld2 = $entryfrm->Entry( -relief => 'sunken' )->pack(-side => 'left'); # , -anchor => 'nw'); my $pmt3 = $entryfrm->Label( # Version -text => 'Version:', -background => 'magenta', )->pack(-side => 'left'); my $fld3 = $entryfrm->Entry( -relief => 'sunken' )->pack(-side => 'left'); my $pmt4 = $entryfrm->Label( # Description -text => 'Description:', -background => 'magenta', )->pack(-side => 'top'); my $fld4 = $entryfrm->Entry( -relief => 'sunken' )->pack(-side => 'top'); MainLoop;

In reply to Perl/Tk: Need Assistance with use of pack() by ozboomer

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.