Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Tk::Checkbutton - text does not line up ...

Reply
Thread Tools

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

 
 
MoshiachNow
Guest
Posts: n/a
 
      09-10-2006
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

 
Reply With Quote
 
 
 
 
Dave
Guest
Posts: n/a
 
      09-10-2006

"MoshiachNow" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.



 
Reply With Quote
 
 
 
 
Ch Lamprecht
Guest
Posts: n/a
 
      09-10-2006
Dave wrote:
> "MoshiachNow" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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/(E-Mail Removed)/"
 
Reply With Quote
 
MoshiachNow
Guest
Posts: n/a
 
      09-11-2006

> 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 !!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read a file line by line and write each line to a file based on the5th byte scad C++ 23 05-17-2009 06:11 PM
Mouse Location to Text line or Text line to location kuna.subramaniyam@gmail.com Javascript 2 04-14-2008 01:46 PM
How to read a text file line by line and remove some line kaushikshome C++ 4 09-10-2006 10:12 PM
Beginner: read $array with line breaks line by line Marek Stepanek Perl Misc 12 09-02-2006 10:27 AM
Read a file line by line with a maximum number of characters per line Hugo Java 10 10-18-2004 11:42 AM



Advertisments