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

Dear Fellow Monks
I have this top-level form that contains a number of radio buttons and an OK button. How can get this frame to disappear once a radio button selection was made and the ok button was pressed?
I have tried ‘destroy’ but it only clears the contents on the frame rather than getting rid of it completely.
Can some one please help me? And many thanks indeed.
my $toplevel = $tk{mw}-> Toplevel; my $top_frame = $toplevel-> Frame; my $folder_level; my $subfolder_level; my $frame_label = $top_frame-> Label(-text=> 'Please select the AC +E permission type'); my @pl = qw/-side top -pady 2 -anchor w/; $top_frame-> pack (@pl); foreach my $p ('No Access', 'List', 'Read', 'Add' ,'Add & Read', ' +Change','Full Controll','Special Directory Accesss','Special File Acc +ess') { $top_frame->Radiobutton( -text => "ACE : $p", -variable => \ + $folder_level, -relief => ' +flat', -value => $ +p, )->pack(@pl); + } my $ok_buttn = $top_frame-> Button(-text=>'OK', -borderwid +t=>5, -width=>10 +, -command=> + sub{print "\n$folder_level\n"; + $top_frame->distroy; } )-> pack;

Replies are listed 'Best First'.
Re: How to get rid of a TopLevel window
by BlueBlazerRegular (Friar) on Sep 11, 2002 at 14:42 UTC
    Assuming that you want to get rid of the entire window (not just the frame widget inside the window), you need to destroy the top-level window, like so:

    $toplevel->destroy;

Re: How to get rid of a TopLevel window
by fglock (Vicar) on Sep 11, 2002 at 14:33 UTC
    s/distroy/destroy/
      Thanks, I realised it was a typo, but what I need is : Change $top_frame->destroy; to $toplevel->destroy;
      Many Thanks to all, It has worked.
      Cheeeeers & respec
Re: How to get rid of a TopLevel window
by Mr. Muskrat (Canon) on Sep 11, 2002 at 14:45 UTC

    Change $top_frame->destroy; to $toplevel->destroy; and it will work. You see you are destroying the frame in the new TopLevel window but not the new TopLevel window itself.

    Update: BlueBlazerRegular beat me to it... That's what I get for trying an example out before posting it. ;)

      Well, I had the advantage of having my code up in VIM already, so I just had to do /destroy to make sure I had things right.

      As past experience has taught, the one time you don't look something up is the time you'll get it wrong.

      Pat