Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Tk - aligning Labels

by Sandy (Curate)
on Sep 14, 2012 at 12:05 UTC ( #993706=note: print w/ replies, xml ) Need Help??


in reply to Tk - aligning Labels

This is actually VERY easy to do, if you use some of the options to LABEL.

Add ,-width=>15,-anchor=>'w' to your Label definitions and it will look much better.

Modified code:

#!/usr/bin/perl use strict; use Tk; my $btypes; my $locations; my $bstats; my $mw; $mw = MainWindow->new; $mw->geometry("400x300"); $mw->title("First App"); my $frmTop = $mw->Frame(-bd => 2,-relief => 'ridge')->pack(-side => 't +op', -fill => 'x', -pady => 3); # Location label/entry my $frmLocations = $frmTop->Frame(-bd => 2)->pack(-side => 'top', -fil +l => 'y'); my $lblLocationsID = $frmLocations->Label(-text => "Locations",-width= +>15,-anchor=>'w')->pack(-side => 'left'); my $edtLocationsID = $frmLocations->Entry(-textvariable => \$locations +,-background => 'white')->pack(-side => 'left'); # type label/entry my $frmLocations = $frmTop->Frame(-bd => 2)->pack(-side => 'top', -fil +l => 'y'); my $lblBtypeID = $frmLocations->Label(-text => "Types",-width=>15, -an +chor=>'w' )->pack(-side => 'left'); my $edtBtypeID = $frmLocations->Entry(-textvariable => \$btypes,-backg +round => 'white')->pack(-side => 'left'); MainLoop;


Comment on Re: Tk - aligning Labels
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993706]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (17)
As of 2015-07-01 16:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (9 votes), past polls