#!/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.
In reply to Re: error:not a Tk object error, please help.
by Khen1950fx
in thread error:not a Tk object error, please help.
by henry888
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |