======== code ========= #!/usr/bin/perl use warnings; use strict; use Tk; my $tl; my $mw = MainWindow->new; $mw->title( "MainWindow" ); my $spawn_button = $mw->Button( -text => "Toplevel", -command => \&do_Toplevel )->pack(); MainLoop; sub do_Toplevel { $spawn_button->configure(-state=>'disabled'); if ( !Exists( $tl ) ) { $tl = $mw->Toplevel(); $tl ->OnDestroy( sub { $tl->withdraw; $spawn_button->configure(-state=>'normal'); } ); $tl->geometry('300x100+100+100'); $tl->title( "Toplevel" ); $tl->Button( -text => "Close", -command => sub { $tl->withdraw; $spawn_button->configure(-state=>'normal'); } )->pack; } else { $tl->deiconify(); $tl->raise(); } } ====================== #### ==================== error message ========= error:not a Tk object Tk::die_with_trace at destroyWinExpert.pl line 22 main::__ANON__ at c:/programs/Perl/lib/Tk/Widget.pm line 363 (eval) at c:/programs/Perl/lib/Tk/Widget.pm line 363 (eval) at c:/programs/Perl/lib/Tk/Widget.pm line 363 Tk::Widget::_Destroyed at c:/programs/Perl/lib/Tk.pm line 411 (eval) at c:/programs/Perl/lib/Tk.pm line 411 Tk::MainLoop at destroyWinExpert.pl line 13 =======