Your solution has a few problems, but if it works for your purposes, that is all that matters. One problem, is that if you click the "StartLongTime.exe" button while it's already running, it will run again when the first run is finished. So you can use the Busy method there. Also, the Dialog does grabs, centers, and needs the funky "selected_button=1" to destroy it. It also is created in the main program, it is better to isolate it in the longtime sub. I would switch to a more flexible toplevel, like this:
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
my $top = new MainWindow;
$top->Button( -text => 'Start LongTime.exe', -command => \&longtime )
->pack;
MainLoop;
sub longtime {
$top->Busy(-recurse => 1);
my $tl = $top->Toplevel();
$tl->overrideredirect(1);
$tl->geometry('300x100+100+100');
$tl->title( "Toplevel" );
$tl->Label( -text => "Working",-bg=>'lightyellow' )
->pack(-expand=>1,-fill=>'both');
$tl->after(10,sub{
system('longtime.exe');
$tl->destroy();
$top->Unbusy(-recurse =>1);
});
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.