I found the answer! This is the routine I use to see if the checkbox value is 1 and then if a toplevel winodw exisits. The method Exists has to be capitalized.
------------------------------------------------- sub do_assists if ($side_on == 0) {print "side on=$side_on\n"; if (Exists($sidew)){ $sidew ->destroy(); } else{#do nothing } } else {if(Exists($sidew)){ #do nothing } else{ $sidew = $mw -> Toplevel(); . . . } ------------------------------------------------- Bob -----Original Message----- From: David Storrs [mailto:[EMAIL PROTECTED] Sent: Thursday, September 25, 2003 7:53 PM To: Robert Greenway Cc: Perl Beginners list Subject: Re: How do I query whether a toplevel window exists? > On Tue, Sep 23, 2003 at 12:04:05PM -0500, Robert Greenway wrote: > > have opened 3 additional toplevel windows in my application for input of > > optional parameters. How can I query if they exist, so I don't recreate > them > > and so I can process them when completed? > > On Wed, Sep 24, 2003 at 10:43:47AM -0500, Robert Greenway wrote: > I am using Perl/tk. I have found out about using the state method. Which has > the values Normal Iconic, and withdrawn. Using that method to test if it > exists causes an error if the window hasn't been created yet. Bob, I'm not particularly familiar with Perl/Tk, so I can't say for sure. However, when you say "causes an error", there should be a solution there. If the error is that it returned undef, then you can test for the undef value (with "defined"). If it throws an exception, then you can trap the exception and test its value. Something like one of these, maybe: eval { $state = $window->state(); }; if ($@ && $@ =~ /Window does not exist/) {} or if (defined $window->state()) { ... } else { ... } (Note that the exception will have some text associated with it, but probably not the literal "Window does not exist" shown above.) As I said above, this is just a guess on my part, but it's something to try. --Dks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]