use strict; use Tk; my $main = MainWindow->new; $main->minsize(qw(350 350)); $main->title("GUI"); $main->configure(); my $left3 = $main->Frame()->pack(-side=>'left'); my $padchk=0; if ($padchk==1) {$padchk=1;} else {$padchk=0;} my $padchk = $left3->Checkbutton(-variable=>\$padchk,-command=> sub{open_menu($padchk)})->pack(); MainLoop; sub open_menu { my $padchk= shift; my $gdsPath= shift; my $text=$left3->Label(-text=> 'enter your name:', -background=>'white'); my $gdsPath=$left3->Entry(); if ($padchk==1){ $text->pack(); $gdsPath->pack(); } elsif ($padchk==0){ $text->destroy; $gdsPath->destroy; $left3->update; } }