Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Padding magic in Perl/Tk

Status
Not open for further replies.

jpasquini

Programmer
Apr 20, 2006
44
US
Hi All,

I am new to Perl but have worked before in UNIX scripting and (gasp) Microsoft Access......anyway what I am trying to do is "center pad" a line of text at the top of the screen.

What I mean is I'd like to have Name, ID, Alias at the upper left corner, and then have the Phone number at the upper right, padding spaces in the middle based on the length of everything.

Is there some simple way to do this in Tk? Here's what I have so far.....Thanks for any advice!

jpasquini


## banner_ids (line #2) ##
$lbl_banner_ids = $frm_banner_ids
-> Label( -text => "UserID: $userid Profile: $profile_name Name: $nameid Phone (to right): $phoneid",
-font => $ss_fixed_width )
-> pack( -side => 'left', -fill => 'x' );
 
Well kids, this is how I ended up doing it. If anyone knows of a better way let me know and I'll be happy to change my ways. Thanks!


## Assign variables
my $label_ids_string = '';
my $label_ids_length = '';
my $label_ids_pad = '';



## Create banner string
$label_ids_string = "UserID: $userid Profile: $profile_name Name: $nameid";
$label_ids_length = 100-length ($label_ids_string)-21; ## length of phoneid string;
$label_ids_pad = ' ' x $label_ids_length;
$label_ids_string = $label_ids_string . $label_ids_pad . "Phone: $phoneid";

## banner ##
$lbl_banner = $frm_banner
-> Label( -text => "VIEW ITEM SCREEN", -font => $ss_main_banner ) ## Or whatever, description of utility
-> pack( -side => 'top', -fill => 'x' );


## banner_ids (line #2) ##
$lbl_banner_ids = $frm_banner_ids
-> Label( -text => $label_ids_string, -font => $ss_fixed_width )
-> pack( -side => 'left', -fill => 'x' );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top