in reply to error:not a Tk object error, please help.

Didn't you see my response at Re^3: how to prevent more than 1 tk Toplevel windows from opening ? By using the onDestroy method, you will get the error because you are trying to withdraw a window as it is being destroyed. Use this to ignore the Window Manager's destroy signal.
if ( !Exists( $tl ) ) { $tl = $mw->Toplevel(); $tl->protocol('WM_DELETE_WINDOW' => sub { print "do nothing here\n"; }); ......
so a complete program would be
#!/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->protocol('WM_DELETE_WINDOW' => sub { print "do nothing here\n"; #prevents destruction +of $tl #by WM control }); $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(); } }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
Re^2: error:not a Tk object error, please help.
by henry888 (Initiate) on May 19, 2008 at 17:19 UTC
    zentara, Your solution is certainly the best and RIGHT one. works well. I did not notice you replied another msg on my another post. How to get notified by email when somebody replies my message ? Thank you very much !!
      Update

      Go to your Homepage, select User settings, then go to Message Settings. Then click the box "send me a message when there is a reply to my posts"

      I don't know about email notification, but you should get a message with a checkbox in the Chatterbox when you logon, showing all replies you've received. Maybe you didn't logon as henry888? Or maybe you have the Chatterbox turned off in your personal settings?


      I'm not really a human, but I play one on earth. Cogito ergo sum a bum