IB2017 has asked for the wisdom of the Perl Monks concerning the following question:
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();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk geometry problem with pack
by tybalt89 (Monsignor) on May 28, 2019 at 02:15 UTC | |
by IB2017 (Pilgrim) on May 28, 2019 at 07:27 UTC | |
by tybalt89 (Monsignor) on May 28, 2019 at 12:19 UTC | |
by tybalt89 (Monsignor) on May 28, 2019 at 12:00 UTC | |
|
Re: Tk geometry problem with pack
by AnomalousMonk (Archbishop) on May 28, 2019 at 05:58 UTC | |
by tybalt89 (Monsignor) on May 28, 2019 at 12:26 UTC | |
|
Re: Tk geometry problem with pack
by tybalt89 (Monsignor) on May 28, 2019 at 00:28 UTC | |
|
Re: Tk geometry problem with pack
by Anonymous Monk on May 29, 2019 at 02:46 UTC |