Justify Tag Option in Text Widget 
Author Message
 Justify Tag Option in Text Widget

Folks-

I'm a bit confused about using the justify tag option in
a text widget. Please refer to this sample program:

use strict;
use Tk;

my $TOP = MainWindow->new;
my $t = $TOP->Text(-wrap => 'none')->pack;

$t->tag('configure', 'LEFT', -justify => 'left');
$t->tag('configure', 'RIGHT', -justify => 'right');

$t->insert("1.0", "Hi There...", 'RIGHT', "How are you?", 'LEFT');

MainLoop();

I would expect the text "Hi There..." to be on the right side
of the line, and the text "How are you?" to be on the left.

In practice this isn't the case, all the text ends up left justified.

Isn't this wrong, or am I just not doing something correctly?

I hope I'm just doing something incorrectly.

Thanks

-Craig Votava
Lucent Technologies
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Wed, 23 Mar 2005 06:30:26 GMT  
 Justify Tag Option in Text Widget
I can't be sure, but usually (ie in programs I've used) justification is
line-based, not word based. So the line is justified to whatever the
last direction given to a word on it was. Try reversing your code to have:

$t->insert("1.0", "Hi There...", 'LEFT', "How are you?", 'RIGHT');

I'm guessing the whole line will now be right-justified.

MB

Quote:

> Folks-

> I'm a bit confused about using the justify tag option in
> a text widget. Please refer to this sample program:

> use strict;
> use Tk;

> my $TOP = MainWindow->new;
> my $t = $TOP->Text(-wrap => 'none')->pack;

> $t->tag('configure', 'LEFT', -justify => 'left');
> $t->tag('configure', 'RIGHT', -justify => 'right');

> $t->insert("1.0", "Hi There...", 'RIGHT', "How are you?", 'LEFT');

> MainLoop();

> I would expect the text "Hi There..." to be on the right side
> of the line, and the text "How are you?" to be on the left.

> In practice this isn't the case, all the text ends up left justified.

> Isn't this wrong, or am I just not doing something correctly?

> I hope I'm just doing something incorrectly.

> Thanks

> -Craig Votava
> Lucent Technologies
> -++**==--++**==--++**==--++**==--++**==--++**==--++**==
> This message was posted through the Stanford campus mailing list
> server.  If you wish to unsubscribe from this mailing list, send the




Fri, 25 Mar 2005 12:42:20 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Text Widget Index Options

2. use HTML tag within Text Widget

3. Read-only text widget tags.

4. Coloring tags in text widget

5. set tabs option in text widget?

6. Text widget's setgrid option

7. Thoughts on Text::Wrap, and perhaps a Text::Justify

8. Listbox have the justify option?

9. Tagged text --> list of tags, revisited

10. right justify text

11. Justifying lines of text?

12. Right justify text

 

 
Powered by phpBB® Forum Software