in reply to help using packForget()
The value you put in $boom will be gone after die exits even if you use local. If you want it to stay, declare it (as my) in a larger block.
Properly formatted code after s/local/my/:
my $boom; sub die { $boom = MainWindow->new( -background=>'green'); # this is where lo +cal was my $label = $boom->Label(); my $yes = $boom->Button(); my $no = $boom->Button(); $label->configure(-text=>'DO you really want to quit?'); $yes->configure(-text=>'Yes',-command=>\&des); $no->configure(-text=>'NO', -command=>\&goback); $label->pack(); $yes->pack(); $no->pack(); } sub goback { $boom->packForget(); } sub des { $boom->packForget(); }
Upd It would be much better not to use global or semi-global variables. This code
die; # creates window 1 die; # creates window 2
will create two windows, but all buttons will control only one of those windows (and after it is closed, buttons will probably generate errors). And this probably happens if your user clicks the "Quit" button twice.
That said, you will be much better off if you use Tk::Dialog for dialog boxes.
|
|---|