Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Tk::LabEntry - justify label?

by gri6507 (Deacon)
on Jan 19, 2005 at 13:56 UTC ( #423377=perlquestion: print w/ replies, xml ) Need Help??
gri6507 has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

After not doing Tk for many many months, I forgot how to use LabEntry. I would like the following two LabEntries:

Begin: _______________ End: _______________

where the labels are right justified. I tried the following code:
$mw->LabEntry(-label=>'Begin', -labelWidth=>7, -labelPack=>[-side=>'le +ft', -anchor=>'w'])->pack(); $mw->LabEntry(-label=>'End', -labelWidth=>7, -labelPack=>[-side=>'left +', -anchor=>'w'])->pack();

but the labels still turn out to be centered instead of right justified as I expected. How do I specify the labels to be right justified?

Thanks much.

Comment on Tk::LabEntry - justify label?
Select or Download Code
Re: Tk::LabEntry - justify label?
by si_lence (Deacon) on Jan 19, 2005 at 17:07 UTC
    Hi
    I think you can get it to look nice by padding with blanks:
    $mw->LabEntry(-label=>' ' x (7 - length 'Begin') . 'Begin' , -labelWi +dth=>7, -labelPack=>[-side=>'left', -anchor=>'w'])->pack(); $mw->LabEntry(-label=>' ' x (7 - length 'End') . 'End', -labelWidth=> +7, -labelPack=>[-side=>'left', -anchor=>'w'])->pack();

    clumsy but it works (as long as you are using a nonpropotional font)
    si_lence
Re: Tk::LabEntry - justify label?
by bibliophile (Parson) on Jan 20, 2005 at 15:41 UTC
    Just a guess... should the -labelPack be: -side => 'right'?

    :-)

    Update:
    According to "Mastering Perl/Tk", it looks like -labelPack's -side only refers to the label's position relative to the entry.
    Perhaps the -labelPack's -anchor should be 'e'?

    I'm making this up as I go along... no access to my dev environment right now :-(

Re: Tk::LabEntry - justify label?
by OfficeLinebacker (Chaplain) on Jul 10, 2007 at 02:19 UTC
    Greetings, esteemed monks!

    I am fighting something very similar, only I am going for

    Date Received:________
    Due Date:_______
    Amount:________
    

    etc--the whole shebang anchored to the left side of the frame. Will report back.

    I like computer programming because it's like Legos for the mind.
Re: Tk::LabEntry - justify label?
by diamantis (Beadle) on Jul 14, 2007 at 13:20 UTC
    I suppose by now you have your problem solved, but since I had a similar problem and found "one more way to do it" the following might be useful to someone

    my $b= $import_w->LabEntry(-label=> 'mytext', -labelPack=>[-side=>'left'] )->pack(-anchor=>'e');
    Right-justifying the entry with pack.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://423377]
Approved by pelagic
Front-paged by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2014-09-15 05:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (145 votes), past polls