A frame-within-frame (within frame...) approach using pack can ease the problems of getting everything to "line up" the way you want. Another geometry manager might be better for an immediate problem, but pack is quite generally useful and the word on the street is that you don't want to mix geometry managers. I don't understand the exact layout you want, but this may serve as a point of departure to help you deal with your centering problems.
File tk_centered_frame_3.pl:

# tk_centered_frame_3.pl 28may19waw use strict; use warnings; use Tk; use Tk::ProgressBar; my %Contents = ( # various fake content percent => [ 0, 1, 50, 90, 100, 120, ], message => [ # user messages 'msg 1', 'user msg 2', 'user message 3 (50%)', 'user message four (90%)', 'user message five (100 percent)', 'really long user message six (120 percent progress)', ], ); die "fake messages and percentages don't match" if @{ $Contents{message} } != @{ $Contents{percent} }; my $MW = MainWindow->new(); my $StatusBar = $MW->Frame() ->pack(qw(-side top -expand 1 -fill x)); use constant STATUS_SUBFRAME_PACK => qw(-side left -expand 1 -fill x +); # define 3 sub-frames in status bar frame. use constant PAGING_SUBFIELD_WIDTH => 9; use constant STATUS_SUBFRAME_WIDTH => PAGING_SUBFIELD_WIDTH * 3; my $UserMessage = "UNDEFINED user message"; my $msg = $StatusBar->Label( -anchor => 'w', -relief => 'flat', -width => STATUS_SUBFRAME_WIDTH, -textvariable => \$UserMessage, )->pack(STATUS_SUBFRAME_PACK); my $paging = $StatusBar->Frame() # to be filled with sub-frames ->pack(STATUS_SUBFRAME_PACK); my $percent_done = undef; my $progress = $StatusBar->ProgressBar( -width => STATUS_SUBFRAME_WIDTH, -length => 200, # -length => STATUS_SUBFRAME_WIDTH, -anchor => 'w', -from => 0, -to => 100, -blocks => 1, -colors => [ 0 => '#93ff66', 50 => '#ffff66', 80 => '#dc143c', ] +, -variable => \$percent_done )->pack(STATUS_SUBFRAME_PACK); # define 3 sub-frames for paging buttons. use constant PAGING_BUTTONS_PACK => qw(-side left -expand 1 -fill bo +th -anchor center); my $ButtonPagingPrevious = $paging->Button( -text => '< Previous', -width => PAGING_SUBFIELD_WIDTH, -command => \&dec_i_content, )->pack(PAGING_BUTTONS_PACK); my $PagingMessage = 'UNDEFINED paging'; my $WidgetShowPaging = $paging->Label( -relief => 'flat', -width => PAGING_SUBFIELD_WIDTH, -textvariable => \$PagingMessage, )->pack(PAGING_BUTTONS_PACK); my $ButtonPagingNext = $paging->Button( -text => 'Next >', -width => PAGING_SUBFIELD_WIDTH, -command => \&inc_i_content, )->pack(PAGING_BUTTONS_PACK); init_fake_content(); $MW->MainLoop(); exit; # subroutines ###################################################### { # begin closure for faking various content my $i_content = 0; sub init_fake_content { $i_content = @_ ? shift : 0; update_user_msg_and_progress($i_content); update_paging_msg($i_content); } sub inc_i_content { ++$i_content; $i_content = 0 if $i_content > $#{ $Contents{percent} }; update_user_msg_and_progress($i_content); update_paging_msg($i_content); } sub dec_i_content { --$i_content; $i_content = $#{ $Contents{percent} } if $i_content < 0; update_user_msg_and_progress($i_content); update_paging_msg($i_content); } sub update_user_msg_and_progress { my $i = shift; $percent_done = $Contents{percent}[$i]; $UserMessage = $Contents{message}[$i]; } sub update_paging_msg { my $i = shift; $PagingMessage = sprintf '%d of %d', 1+$i, scalar @{ $Contents{message} }; } } # end closure for faking various content


Give a man a fish:  <%-{-{-{-<


In reply to Re: Tk geometry problem with pack by AnomalousMonk
in thread Tk geometry problem with pack by IB2017

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.