henry888 has asked for the wisdom of the Perl Monks concerning the following question:
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 =======
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: error:not a Tk object error, please help.
by Khen1950fx (Canon) on May 19, 2008 at 08:02 UTC | |
by Anonymous Monk on May 19, 2008 at 08:26 UTC | |
by Khen1950fx (Canon) on May 19, 2008 at 09:22 UTC | |
by Anonymous Monk on May 19, 2008 at 10:48 UTC | |
|
Re: error:not a Tk object error, please help.
by Anonymous Monk on May 19, 2008 at 07:59 UTC | |
by Anonymous Monk on May 19, 2008 at 08:01 UTC | |
|
Re: error:not a Tk object error, please help.
by zentara (Cardinal) on May 19, 2008 at 13:37 UTC | |
by henry888 (Initiate) on May 19, 2008 at 17:19 UTC | |
by zentara (Cardinal) on May 19, 2008 at 17:26 UTC |