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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |