There are alot of ways to do what you want. Basically you need to test for some condiition(i.e. a finished flag), then close the window. Usually you use a timer to do this, but there are other ways. Also, if you call "PoP-It" more than once, you will be gaining memory-size with each call, since you destroy (then recreate) $tp.
Only create $tp once, and call withdraw and deiconify on it to reuse the widget.
sub AddItem {
my $tp = $mw->Toplevel(
-title => ' AddItem'
); # ->pack(-fill => 'both');
my $tpfrm = $tp->Frame(
-background => '#22cc00',
)->pack(-side => 'top', -fill => 'x');
my $tplbl = $tpfrm->Label(
-text => 'Working...',
-background => 'white',
-foreground => 'black'
)->pack(-side => 'top', -padx => 10);
# my $tpbtn = $tpfrm->Button(
# -text => 'Close',
# -command => [$tp => 'destroy'],
# )->pack(-side => 'top', -padx => 10, -pady => 5);
#start a timer to simulate some working being done
my $count = 0;
my $timer = $mw->repeat(1000,sub{
$count++;
if($count == 5){ $tp->withdraw }
});
}
I'm not really a human, but I play one on earth.
flash japh
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.