Re: handling SIGINT in a Tk application
by Ondrej Koala Vacha other posts by this author
May 27 2004 9:00PM messages near this date
Re: handling SIGINT in a Tk application
|
Re: handling SIGINT in a Tk application
On Thu, 27 May 2004, Petr Pajas wrote:
> Hi Nick, All,
>
> I'd like to trap SIGINT and do some cleanup (that doesn't require user
> interaction) before closing the main window. If I simply setup
> $SIG{INT} = sub {...}, it works, except that the signal isn't
> processed until the main window regains focus, which requires
> e.g. moving a mouse. I'd like the app to exit immediately when I press
> Ctrl+C in an xterm. What am I doing wrong? This behaviour may be
> platform specific, I'm not sure. I'm running RH9 Linux, KDE 3.2.2,
> perl 5.8.2, Tk804.027. A test case app follows.
>
> #!/usr/bin/perl
> package main;
>
> use Tk;
> $top = MainWindow->new;
> $top->Label(-text => 'Press Ctrl+C in the console!')->pack();
> $SIG{INT} = sub {
> print "Ctrl+C pressed\n";
> $top->destroy;
> };
> MainLoop;
> __END__
>
I start this code in xterm. After Ctrl+C no action,
but $SIG{INT} sub is executed when the Tk window will get focus.
--
Ondrej Koala Vacha
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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 majordomo@lists.stanford.edu
Thread:
Ondrej Koala Vacha
Steve Lidie
Nick Ing-Simmons
Ondrej Koala Vacha
Steve Lidie
|