$mw = MainWindow->new(); $mw->Button(-text=>"A", -command=>\&start)->pack(); MainLoop; sub start { $tl=$mw->Toplevel(); $tl->Button(-text=>"B", -command=>sub{destroy $tl})->pack(); }