http://www.perlmonks.org?node_id=1185225

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

Dear Perlmonk experts,

I'm designing my simple GUI and i could not find a way to get rid of the spaces between the label and entry box in my output GUI and align them. Please advice on what will be the best way to do this.

Thank you.

use strict; # module to must always declare variabl +es 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{exi +t}, -state => 'disabled'); $file_menu->command(-label=>"Exit", -underline=>0, -command=>sub{ex +it}); # About $main_menu->command(-label=>"About", -command=>sub{$mainwindow->messag +eBox(-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 $label_firstname = $mainwindow->Label(-text => 'Firstname:')->pack (-a +nchor => 'nw'); $entry_firstname = $mainwindow->Entry(-width => 35,-text => 'Firstname +')->pack (-anchor => 'n' ); $label_lastname = $mainwindow->Label(-text => 'Lastname:')->pack (-anc +hor => 'nw'); $entry_lastname = $mainwindow->Entry(-width => 35,-text => 'Lastname') +->pack (-anchor => 'n'); $label_loginid = $mainwindow->Label(-text => 'Login ID:')->pack( -anch +or => 'nw'); $entry_loginid = $mainwindow->Entry(-width => 35,-text => 'loginID')-> +pack (-anchor => 'n'); $button_add = $mainwindow->Button(-text => 'Add New User', -command=>s +ub{exit})->pack(-anchor => 'se'); MainLoop();