Sounds like you want your error window to do a grab. The main window of this
prog has 2 buttons. One to print 'Hello' and one to raise a second window by
calling sub do_toplevel. The grab in sub do_toplevel makes $tL modal, i.e.
no buttons on $mw will work until $tL is closed. Try pressing the "Print
'Hello'" button before and after $tL is raised.

use Tk;
use Tk::TopLevel;

$mw = MainWindow->new;
$mw->title("MainWindow");
$mw->Button(-text => "Toplevel", -command => \&do_toplevel)->pack();
$mw->Button(-text => "Print 'Hello'", -command => sub {print
"Hello"})->pack();

MainLoop;

sub do_toplevel{
        if (! Exists($tL)){
                $tL = $mw->Toplevel();
                $tL->title("Toplevel");
                $tL->Button(-text=>"Close",
                            -command => sub  {$mw->configure(-takefocus => 1); # 
doesn't
make it modal
                                              $tL->withdraw ;
                                              $tL->grabRelease;
                                              print "close button chosen\n";

                                              })->pack;
        } else {
                $tL->deiconify();
                $tL->raise();
        }
        $mw->configure(-takefocus =>0); # doesn't make it modal
        $tL->transient($mw);     # doesn't make it modal
        $tL->group($mw); # doesn't make it modal
        $tL->grab       # makes modal!
        ;
}

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Helton, Brandon
Sent: Wednesday, January 10, 2001 3:50 PM
To: '[EMAIL PROTECTED]'
Subject: Locking window focus


This is probably a trivial question, but here goes.  I need to know how I
can
"lock" users from clicking on parent windows when an alert or error window
pops
up.  That way the user must press Ok or Cancel or whatever in order to
continue
using the tool.  I'm looking for something like the alert popup in
javascript.
Is this something that can be done with Perl/Tk and if so could someone
kindly
explain how?  Thanks,

Brandon
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to [EMAIL PROTECTED]

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to