in reply to How can I find out whether a Tk Toplevel widget has been destroyed?

I think you are asking about the Exists method: i'm not an expert but i have use in my Tk Tartaglia's triangle fun - Pascal's triangle fun. Here the relevant part (found in subs: destroy_tri draw_triangle):
if (! Exists($top_lvl_win)) { $top_lvl_win= $mw->Toplevel();
See also zentara's example: Re: How do I determine if a Tk window exists?
The Exists method is in Widget.


HtH
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: How can I find out whether a Tk Toplevel widget has been destroyed?
by tkguifan (Scribe) on Feb 18, 2015 at 08:47 UTC
    It works for me:
    use Tk; my $mw=new MainWindow; my $toplevel; my $toplevel_open=0; my $status=$mw->Label(-text=>'Toplevel Closed :(')->pack; $mw->repeat(1000,sub { $status->configure(-text=>Exists($toplevel)? 'Toplevel Open :)':'Toplevel Closed :('); } ); sub close_toplevel { return if !Exists($toplevel); $toplevel->destroy; } $mw->Button(-text=>'Open Toplevel',-command=> sub { $toplevel=$mw->Toplevel(); } )->pack; $mw->Button(-text=>'Close Toplevel',-command=>\&close_toplevel)->pack; MainLoop;