Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: DialogBox that persists awhile

by tybalt89 (Monsignor)
on Jul 06, 2020 at 20:29 UTC ( [id://11118982]=note: print w/replies, xml ) Need Help??


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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11118982]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-24 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found