Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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.

Replies are listed 'Best First'.
Re: Tk::LabEntry - justify label?
by si_lence (Deacon) on Jan 19, 2005 at 17:07 UTC
    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)
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'?


    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 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.
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:_______

    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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://423377]
Approved by pelagic
Front-paged by Courage
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2017-04-30 07:49 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (534 votes). Check out past polls.