http://qs321.pair.com?node_id=11118982


in reply to DialogBox that persists awhile

You didn't provide a Short, Self-Contained, Correct Example so I tossed a bunch of guesses into a pot and stirred...

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11118943 use warnings; use Tk; use Tk::DialogBox; use Time::HiRes qw( sleep ); { # start package package Tk::AltDialogBox; use base qw( Tk::DialogBox ); Tk::Widget->Construct('AltDialogBox'); sub Wait { my $cw = shift; $cw->Callback(-showcommand => $cw); $cw->waitVariable(\$cw->{'selected_button'}); $cw->grabRelease if Tk::Exists($cw); $cw->Callback(-command => $cw->{'selected_button'}); # swapped with +next line $cw->withdraw if Tk::Exists($cw); } } # end package my $message = ' '; my $mw = MainWindow->new; $mw->geometry( '200x200+1000+300' ); my $lb; my $d; $d = $mw->AltDialogBox( -buttons => ['OK', 'Cancel'], -command => sub { my $value = $lb->get($lb->curselection // 0); $message = "working on $_ ...\n", $d->update, sleep 0.3 for 1 .. 1 +0; print "exited by @_ with $value\n"; }, -showcommand => sub { $lb->selectionClear(0, 'end'); $lb->selectionSet(0); $message = ' '; }, ); $lb = $d->add(Listbox => -height => 10)->pack; $d->add(Label => -textvariable => \$message, -height => 2)->pack; $lb->insert('end' => 1 .. 5); $mw->Button(-text => 'See Dialog', -command => sub { $d->Show }, )->pack; MainLoop;