Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Tk::Checkbutton - text does not line up ... (http://www.velocityreviews.com/forums/t899848-tk-checkbutton-text-does-not-line-up.html)

MoshiachNow 09-10-2006 08:25 AM

Tk::Checkbutton - text does not line up ...
 
HI,

Using a function on Windows,I define a $test variable as following:

$text=sprintf("%-35s %-13s",$_,'(directory)');

Then define the checkbutton:

$button[$i] = $dialog5->Checkbutton(-text => "$text",-variable =>
\($var->{$_}),-relief => 'flat')->pack(@pl);

The text in $text DOES NOT get lined up !

If at the same time I print $text to the black window

print "$text\n";

the text DOES look lined up.

What is wrong ?
Thanks


Dave 09-10-2006 01:50 PM

Re: Tk::Checkbutton - text does not line up ...
 

"MoshiachNow" <lev.weissman@creo.com> wrote in message
news:1157876721.088230.130660@m79g2000cwm.googlegr oups.com...
> HI,
>
> Using a function on Windows,I define a $test variable as following:
>
> $text=sprintf("%-35s %-13s",$_,'(directory)');
>
> Then define the checkbutton:
>
> $button[$i] = $dialog5->Checkbutton(-text => "$text",-variable =>
> \($var->{$_}),-relief => 'flat')->pack(@pl);
>
> The text in $text DOES NOT get lined up !
>
> If at the same time I print $text to the black window
>
> print "$text\n";
>
> the text DOES look lined up.
>
> What is wrong ?
> Thanks
>


By default the text is 'center' anchored; you probably don't want this so
try setting the -anchor option, e.g. anchor => 'w', as appropriate.




Ch Lamprecht 09-10-2006 03:28 PM

Re: Tk::Checkbutton - text does not line up ...
 
Dave wrote:
> "MoshiachNow" <lev.weissman@creo.com> wrote in message
> news:1157876721.088230.130660@m79g2000cwm.googlegr oups.com...
>
>>HI,
>>
>>Using a function on Windows,I define a $test variable as following:
>>
>>$text=sprintf("%-35s %-13s",$_,'(directory)');
>>
>>Then define the checkbutton:


>>The text in $text DOES NOT get lined up !


>
>
> By default the text is 'center' anchored; you probably don't want this so
> try setting the -anchor option, e.g. anchor => 'w', as appropriate.
>
>
>

In addition you might consider using a fixed-width font to have the second part
of your label aligned vertically as well:

use strict;
use warnings;
use Tk;
my $mw = tkinit();
my @text =
map {sprintf("%-35s %-13s",$_,'(directory)')
} qw(test something_else);
my @buttons =
map {$mw->Checkbutton(-text => $text[$_],
-font=>[courier => 9]
)->pack(-anchor=>'w')
} (0,1);

MainLoop();


Christoph


--

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"

MoshiachNow 09-11-2006 07:21 AM

Re: Tk::Checkbutton - text does not line up ...
 

> In addition you might consider using a fixed-width font to have the second part
> of your label aligned vertically as well:



Thanks !

This worked like magic !!



All times are GMT. The time now is 10:46 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.