use strict; use Tk; use Tk::WaitBox; use Tk::ProgressBar; my($root) = MainWindow->new; my($utxt) = "Initializing..."; my($percent); my($wd); $wd = $root->WaitBox( -bitmap =>'questhead', # Default would be 'hourglass' -txt2 => 'tick-tick-tick', #default would be 'Please Wait' -title => 'Takes forever to get service around here', -cancelroutine => sub { print "\nI'm cancelling....\n"; $wd->unShow; $utxt = undef; } ); ### Do something quite boring with the user frame my($u) = $wd->{SubWidget}{uframe}; $u->configure (-relief => 'groove', -borderwidth => 5); $u->pack(-expand => 1, -fill => 'both'); $u->Label(-textvariable => \$utxt)->pack(-expand => 1, -fill => 'both'); ## It would definitely be better to do this with a canvas... this is dumb my($bar) = $u->ProgressBar( -variable => \$percent, -blocks => 0, -width => 20, -relief => 'sunken', ) ->pack(-expand =>1, -fill =>'both'); $wd->configure(-canceltext => 'Halt, Cease, Desist'); # default is 'Cancel' $wd->Show; my($diff) = 20; for (1..$diff) { sleep(1); $percent = int($_/$diff*100); $utxt = sprintf("%5.2f%% Complete",$percent); $root->update; last if !defined($utxt); } $wd->unShow; MainLoop;