Dear monks, I'm trying to create TK application where some values (Entry widget) should be entered by a user. This values should have a description (Label widget) on right side of them. The problem is to have the description just after the corresponding Entry widget. I'm pretty shure I missed some important but can't find any advice in the docs how to manage this kind of positioning.
This is a picture I want:
-- |5 | Enter the number of daily log files to copy -- -- |5 | Enter the number of audit log files to copy --
This is what i get now:
-- |5 | Enter the number of + daily log files to copy -- -- |5 | Enter the number of audit log files to copy --

It look like the left border of the first Label starts where right border of the second label is. I tried to add some free space using ipadx and ipady statements to the pack operator but didn't managed to get appropriate result.
use Modern::Perl; use Tk; my %config = ( numberOfDailyLogsToCopy => 5, numberOfAuditLogsToCopy => 5, ); my $mainWindow = MainWindow->new( -title => "main window", ); my $chkboxFrame = $mainWindow -> Frame( -borderwidth => 2, ) +->pack( -anchor => 'w', ); my $entryDailyLogs = $chkboxFrame -> Entry( -textvariable => \$config{'numberOfDailyLo +gsToCopy'}, -width => 2, ) -> pack( -anchor => 'w',); my $entryDailyLogsText = $chkboxFrame -> Label( -text => 'Enter the number of daily log fi +les to copy', ) -> pack( -before => $entryDailyLogs, -si +de => 'right' ); my $entryAuditLogs = $chkboxFrame -> Entry( -textvariable =>\$config{'numberOfAuditLog +sToCopy'}, -width => 2, ) -> pack( -anchor => 'w', ); my $entryAuditLogsText = $chkboxFrame -> Label( -text => 'Enter the number of audit log fi +les to copy', ) -> pack( -before => $entryAuditLogs, -si +de => 'right'); MainLoop;

With an additional frame everything is works fine:
use Modern::Perl; use Tk; my %config = ( numberOfDailyLogsToCopy => 5, numberOfAuditLogsToCopy => 5, ); my $mainWindow = MainWindow->new( -title => "main window", ); my $dailyFrame = $mainWindow -> Frame( -borderwidth => 2, ) - +>pack(); my $entryDailyLogs = $dailyFrame -> Entry( -textvariable => \$config{'numberOfDailyLo +gsToCopy'}, -width => 2, ) -> pack( -side => 'left', -anchor => 'w' +); my $entryDailyLogsText = $dailyFrame -> Label( -text => 'Enter the number of daily log fi +les to copy', ) -> pack( -side => 'left' ); my $auditFrame = $mainWindow -> Frame( -borderwidth => 2, + ) ->pack(); my $entryAuditLogs = $auditFrame -> Entry( -textvariable =>\$config{'numberOfAuditLog +sToCopy'}, -width => 2, ) -> pack( -side => 'left', -anchor => 'w' + ); my $entryAuditLogsText = $auditFrame -> Label( -text => 'Enter the number of audit log fi +les to copy', ) -> pack( -side => 'left' ); MainLoop;

I'm just wondering if there is an easier possibility to adjust the labels without adding a frame for each pair of elements.
Thank you in advance.

In reply to TK positioning of elements by wwe

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.