in reply to error:not a Tk object error, please help.
#!/usr/bin/perl use strict; use warnings; use Tk; my $t1; 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 => 'normal'); if ( !Exists( $t1 ) ) { $t1 = $mw->Toplevel(); sub { $t1->withdraw; $spawn_button->configure(-state => 'disabled'); $t1->geometry('300x100+100+100'); $t1->title( "Toplevel" ); $t1->Button( -text => "Close", -command => sub { $t1->withdraw; $spawn_button->configure(-state => 'normal'); } )->pack; } } else { $t1->deiconify(); $t1->raise(); } }
update: Strange, but the script on my computer worked, but after downloading the script from perlmonks---it doesn't work. Sorry...
update: Fixed, it should work now.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: error:not a Tk object error, please help.
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 |