Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks! I have some code and I can't figure out how to left justify. I've check the Tcl::Tk can page but I can't find anything. Here's a tear out of my code

my $frame_border_bottom = $mw->Frame( -relief => "flat" ); my $welcome_label_bottom = $frame_border_bottom->Label( -text => "Searching for Keywords/City + pairs \n" ); $frame_border_bottom->grid( -row => 7, -column => 3, -columnspan = +> 6 ); $welcome_label_bottom->grid( -row => 7, -column => 3, -columnspan +=> 6 );

Thanks in advance for the help.

Replies are listed 'Best First'.
Re: Justify text Tcl::Tk grid
by Anonymous Monk on Mar 09, 2016 at 21:34 UTC
    Use sticky option of grid to justify the label

      I did a few google searches and didn't find much other than this:

      my $welcome_label_bottom = $frame_border_bottom->Label( -text => "Progress Update: \n" )->pac +k(-side=>'right', -anchor=>'n');

      but it doesn't seem to work

      what would the sticky option of grid code look like? - thanks!</p?

        "what would the sticky option of grid code look like?"

        See the Tk::grid documentation.

        See the "Tk distribution page" for links to the documentation for all the core Tk::* modules.

        — Ken

Re: Justify text Tcl::Tk
by dbuckhal (Chaplain) on Mar 10, 2016 at 16:18 UTC
    How about thinking outside the "Tk box" and pre-format your text before you assign it to the text attribute:
    $ perl -le ' $left = sprintf( ">>%-10s<<", "left" ); $right = sprintf( ">>%10s<<", "right" ); print "$left\n"; print "$right\n"; ' __output__ >>left << >> right<<
    Hope it helps!