in reply to Perl Tk: pack option does't work
There is no need to create/destroy labels, this is how you should write that
It doesn't fix the centering/layout issue, maybe this tutorial can help#!/usr/bin/perl -- use strict; use warnings; use Tk; use Tk::Pane; my $mw = MainWindow->new(); $mw->geometry("100x100"); $mw->Button( -text => "START", -command => \&start_computation )->pack +; MainLoop; sub start_computation { my $progress = $mw->Toplevel(); $progress->geometry("100x100"); my $pane = $progress->Scrolled( 'Pane', -scrollbars => 'osoe', -background => 'red', )->pack( -fill => 'both', -expand => 'yes', ); my $text = "Computation started...\n"; my $label = $pane->Label( -textvariable => \$text, )->pack( -side => 'right', ); # doing several computation steps for my $step ( 1 .. 10 ) { sleep(1); $text .= "Step $step finished.\n"; $pane->update; } $text .= "\nComputation finished.\n"; $pane->update; $pane->Button( -text => "QUIT", -command => sub { exit; } )->pack( -anchor => 'nw', ); return; } ## end sub start_computation
|
|---|