#!/usr/bin/perl # http://perlmonks.org/?node_id=1185225 use strict; # module to must always declare variables before you + use them use warnings; # module to show where is the error use Tk; # module for the Windows GUI my $mainwindow = MainWindow->new(); $mainwindow->geometry("600x150"); $mainwindow->title("Window"); # Disable the window Resize $mainwindow->resizable(0,0); # Menu display option my $main_menu = $mainwindow->Menu(); $mainwindow->configure(-menu => $main_menu); #File my $file_menu = $main_menu->cascade(-label=>"File", -underline => 0, - +tearoff=>0); $file_menu->command(-label=>"New", -underline=>0, -command=>sub{exit}, -state => 'disabled'); $file_menu->command(-label=>"Exit", -underline=>0, -command=>sub{ex +it}); # About $main_menu->command(-label=>"About", -command=>sub{$mainwindow->messageBox(-title=> "About", -message=>"Version 3.0.0", -type => "ok")}); # text variable my $label_firstname; my $entry_firstname; my $label_lastname; my $entry_lastname; my $label_loginid; my $entry_loginid; my $button_add; # -anchor => 'e' | 'w' | 'n' | 's' | 'ne' | 'nw' | 'se' | 'sw' | 'cen +ter' # top ################################ # nw n ne # # # # w center e # # # # sw s se # ################################ # bottom my $f1 = $mainwindow->Frame->pack; $label_firstname = $f1->Label(-text => 'Firstname:', -width => 10, -an +chor => 'e', )->pack (-side => 'left'); $entry_firstname = $f1->Entry(-width => 35,-text => 'Firstname', )->pack (-side => 'left'); my $f2 = $mainwindow->Frame->pack; $label_lastname = $f2->Label(-text => 'Lastname:', -width => 10, -anch +or => 'e', )->pack (-side => 'left'); $entry_lastname = $f2->Entry(-width => 35,-text => 'Lastname', )->pack (-side => 'left'); my $f3 = $mainwindow->Frame->pack; $label_loginid = $f3->Label(-text => 'Login ID:', -width => 10, -ancho +r => 'e', )->pack( -side => 'left'); $entry_loginid = $f3->Entry(-width => 35,-text => 'loginID', )->pack (-side => 'left'); $button_add = $mainwindow->Button(-text => 'Add New User', -command=>sub{exit})->pack(-anchor => 'se'); MainLoop();

Though I agree with the monks that suggest using ->grid


In reply to Re: how to align the label and entry text box in my tk GUI by tybalt89
in thread how to align the label and entry text box in my tk GUI by fsmendoza

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.