http://www.perlmonks.org?node_id=192188

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

Once again I find myself asking for wisdom

I have a Tk window that at the click of a button will spawn a pop-up window. Is there a way to force the user to interact with the pop-up before going back to the parent window? I want to avoid the user going back to the parent window and spawing multiple pop-up windows before dispatching previous ones.
 Thank you

Replies are listed 'Best First'.
Re: perl Tk focus question
by dree (Monsignor) on Aug 22, 2002 at 22:20 UTC
    You can use the grab() function for the second window.
    See the example below:
    use strict; use Tk; my $mw = MainWindow->new( -height => 385, -width => 575); $mw->title ("Example"); #---------- Adding Button my $button = $mw->Button( -text => "Click me!", -relief => "raised", "-command"=>\&Click_me, ); $button->place( -x => 215, -y => 295, -height => 22, -width => 90); MainLoop; sub Click_me { my $mw2 = $mw->Toplevel( -height => 123, -width => 245); $mw2->title (""); $mw2->grab(); }