kranthi has asked for the wisdom of the Perl Monks concerning the following question:

Hi Perl Monks,
Is there any specific method through which we can identify if a toplevel window is closed or opened?

Replies are listed 'Best First'.
Re: Need info regarding Toplevel
by zentara (Cardinal) on Jun 11, 2008 at 12:55 UTC
    $toplevel->ismapped
    #!/usr/bin/perl use warnings; use strict; use Tk; my $tl; my $mw = MainWindow->new; $mw->title( "MainWindow" ); $mw->Button( -text => "Toplevel", -command => \&do_Toplevel )->pack(); $mw->Button( -text => "Check Mapping", -command => \&check_mapping )-> +pack(); &do_Toplevel; MainLoop; sub check_mapping{ if ($tl->ismapped){ print "toplevel is mapped\n" } else { print "toplevel is unmapped\n" } } sub do_Toplevel { if ( !Exists( $tl ) ) { $tl = $mw->Toplevel(); $tl->geometry('300x100+100+100'); $tl->title( "Toplevel" ); $tl->Button( -text => "Close", -command => sub { $tl->withdraw } )->pack; } else { $tl->deiconify(); $tl->raise(); } }

    I'm not really a human, but I play one on earth CandyGram for Mongo
Re: Need info regarding Toplevel
by GrandFather (Saint) on Jun 11, 2008 at 11:35 UTC

    Exists ($widget) does something like that job for particular values of 'closed' and 'opened'. See Tk::Widget.


    Perl is environmentally friendly - it saves trees
Re: Need info regarding Toplevel
by Anonymous Monk on Jun 11, 2008 at 11:06 UTC