#!/usr/bin/perl my $top2 = MainWindow->new(); my $waitbox = $top2->WaitBox(-title=>"Connecting to agent $port", -txt1=>"Connecting to Agent $port.\nConnection will be establ +ished when this box closes.\n", -cancelroutine=>sub { print "\nCancelling...\n"; $top2->unShow; die} ); # pack the widgets $waitbox->pack; # encapsulate the wait box posting # and the connect routine in a sub # ( the waitbox is just using a "grab" and "focus", # if you want to roll your own, see Tk::Grab ) sub doyourstuff { # post the waitbox, this doesn't block # the process, it just grabs all the keyboard # and mouse events and discards them for a while $waitbox->Show; # do your connect stuff here for (1..10) { print STDERR "waiting $_\n"; sleep(1); } # get rid of the waitbox and start taking mouse/kb # events again. $waitbox->unShow; } # schedule the doyourstuff subroutine to # run in 0 ms $top2->after(0,\&doyourstuff); MainLoop();