But when the user close the main window directly, user will see some error message:======== 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(); } } ======================
Please help !! THanks==================== 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 =======
In reply to error:not a Tk object error, please help. by henry888
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |