JohnMatthews has asked for the wisdom of the Perl Monks concerning the following question:

Hello,
I'm having a little fun playing with perl/tk on an NT4 platform. I seem to be having problems closing Tk::Toplevel windows as part of a -command switch for button widgets. When the add button on the addgroupswindow is pressed, addgroups() is run, but the addgroupswindow toplevel is not destroyed.
use Tk; use Tk::DialogBox; use Tk::Dialog; use Tk::Label; use Tk::Entry; use Tk::Tree; use Win32::Process; my $Mainwindow = MainWindow->new; #? my $firstname = $Mainwindow->Entry (-width=>30); $firstname ->grid(-row => 0, -col => 1); #? my $groupstouserbutton = $Mainwindow->Button (-text => "add to groups", -command => sub { addgroupswindowmaker($firstname)}); $groupstouserbutton ->grid(-row=>19, -col=>1); #? my $quitbutton = $Mainwindow->Button (-text => "Quit", -command => [$Mainwindow => 'destroy']); $quitbutton ->grid(-row=>20, -col=>1); MainLoop; sub addgroupswindowmaker { $addgroupswindow = $Mainwindow->Scrolled(Toplevel, -scrollbars => 'osoe'); $addgroupswindow->title("Potato"); #? my $addgroupsbutton = $addgroupswindow->Button (-text => "Add", -command => sub { addgroups();$addgroupswindow => 'destroy +'})->grid(-row=> $k,-col => "1"); my $cancelgroupsbutton = $addgroupswindow->Button (-text => "Done", -command => [$addgroupswindow => 'destroy'])->grid(-row=> +$k,-col => "2"); } sub addgroups{ #? }

Replies are listed 'Best First'.
Re: Closing Tk::Toplevel windows.
by JohnMatthews (Initiate) on May 07, 2003 at 01:23 UTC
    Erm, slight embarrassment, I found out about destroy(); I feel foolish now.
Re: Closing Tk::Toplevel windows.
by nite_man (Deacon) on May 07, 2003 at 06:40 UTC
    Maybe this Tk Documentation will be useful for you.
          
    --------------------------------
    SV* sv_bless(SV* sv, HV* stash);