#!/usr/bin/perl -- use strict; use warnings; use Tk; my $packArgs = do { my @packargs = ( [ qw/-expand 0 / ], [ qw/-expand 1 -fill x / ], [ qw/-expand 1 -fill y / ], [ qw/-expand 1 -fill both / ], ); my $ix = -1; my $xx = @packargs ; sub { $ix++; warn $ix % $xx ; return @{ $packargs[ $ix % $xx ] }; }; }; my $mw = tkinit; $mw->Button( -text => 'BANG!', -command => \&bangBang )->pack(qw/-side top -anchor n/); my $ca = $mw->Canvas( background => 'white' ) ->pack( $packArgs->() ); $ca->createOval( 50, 50, 100, 100, -fill => 'pink', ); MainLoop; exit 0; sub bangBang { my $b = $Tk::event->W; $mw->Busy; $b->configure(-state => "disabled"); my $text = $b->cget(qw/ -text /); unless( $text =~ s/(\d+)/ $1 + 1 /e ){ $text .= " 1"; } $b->configure( -text => $text); $ca->packForget; $mw->update; sleep 1; $ca->pack( $packArgs->() ); $mw->Unbusy; $b->configure(-state => "normal"); $mw->update; }