Hello Monks

I have a GUI written in Tk. I have created a custom status bar (script below) to be put at the bottom of the GUI. The status bar has three elements: a) left side: a variable message for the user; b) center: a paging menu and c) right: a progress bar. All three parts are optional, i.e. I display them only if needed by the current actions. What I would like to achieve is that part b) is always centered in the Frame, no matter what the left label looks like or if the progressbar is shown or not. Is it possible to have this Frame always centered using pack?

use strict; use warnings; use Tk; use Tk::ProgressBar; my $mw = MainWindow->new(); my $percent_done; my $UserMessage; my $PagingMessage="10 of 20"; my $UserMessage="this is my user message"; $mw->Label( -anchor => 'w', -relief => 'flat', -textvariable => \$UserMessage, )->pack(-side => 'left', -expand => 0 , -fill =>'both'); my $FramePaging = $mw->Frame()->pack(-side=>'left', -padx=>20, -fill=> +'none' ); my $ButtonPagingNext = $FramePaging->Button( -text=> " Next > ", )->pack(-side => 'right', -anchor=>'center', -expand => 1 , -f +ill =>'both'); my $WidgetShowPaging = $FramePaging->Label( -anchor => 'w', -relief => 'flat', -textvariable => \$PagingMessage, )->pack(-side => 'right', -anchor=>'center', -expand => 1 , -f +ill =>'both'); my $ButtonPagingPrevious = $FramePaging->Button( -text=> " < Previous ", )->pack(-side => 'right', -anchor=>'center', -expand => 1 , -f +ill =>'both'); $mw->ProgressBar( -width => 20, -length => 200, -anchor => 'w', -from => 0, -to => 100, -blocks => 1, -colors => [0, '#93ff66', 50, '#ffff66' , 80, '#dc143c'], -variable => \$percent_done )->pack(-side=>'right', -padx=>5, -pady=>5, -fill=>'x' ); $mw->MainLoop();

In reply to 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.