in reply to Perl tk [ Tk::Text -justify option is not working

You are probably using justify wrong. In a text widget, it is a tag option. Does this work?
#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Text; use strict; my $mw = MainWindow->new; my $t = $mw->Scrolled('Text', -scrollbars=> 'se', -height=> 5, -background =>'white', -wrap => 'none') ->pack(-side=>'bottom', -fill=> 'both', -expand=> '1'); $t->tagConfigure('right', -justify => 'right'); $t->insert('end',"This is a right justified, none wrapping text.\n",'r +ight'); $t->insert('end','Try to type some text over the left edge of the wind +ow here: ','right'); $t->focus; MainLoop;

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku

Replies are listed 'Best First'.
Re^2: Perl tk [ Tk::Text -justify option is not working
by ungalnanban (Pilgrim) on Mar 01, 2010 at 07:22 UTC
    Hi.. I used Text widget so I wrote my code like.
    $align -> command(-label =>"Left",-command=>sub { #$txt->configure( -justify =>'left'); $txt->tagConfigure('left', -justify => 'left'); } ); $align -> command(-label =>"Right",-command=>sub { #$txt->configure(-justify=>'right'); $txt->tagConfigure('right', -justify => 'right'); } ); $align -> command(-label =>"Center",-command=>sub { #$txt->configure(-justify=>'center'); $txt->tagConfigure('center', -justify => 'center'); } );

    but the text in the Text widget are not aligned to left,right or center.
    How can I achieve the text alignment option in Text widget?

      I don't see a running code example, but the Tk demo "widget" has a text example which shows centered tag usage.
      $t->tag(qw/configure center -justify center/);

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku