Re: blocking code after main loop
- From: Sergei Steshenko <sergstesh yahoo com>
- To: Michael Hartmann <michael hartmann as-netz de>, gtk-perl-list gnome org
- Subject: Re: blocking code after main loop
- Date: Mon, 9 Oct 2006 14:28:16 -0700 (PDT)
--- Michael Hartmann <michael hartmann as-netz de> wrote:
Hi,
I have a script where I need to run code after the user closed the GTK2 gui. I
need to run blocking code.
The program works similar to this very simple script:
#!/usr/bin/perl -w
use strict;
use Gtk2 "-init";
my $window = Gtk2::Window->new;
$window->signal_connect("delete-event" => sub { Gtk2->main_quit; 0;});
my $button = Gtk2::Button->new("Close me");
$button->signal_connect(clicked => sub { Gtk2->main_quit; } );
$window->add($button);
$window->show_all;
Gtk2->main;
sleep 10; # blocking code
When you close the gui using the button, it doesn't disappear immediatly. In
fact the sleep function seems to block the gui. This is quite ugly, because
the user clicks on the button and the gui "hangs".
However, I don't understand why there is still the gui available.
Up to now I thougt Gtk2->main is a method that blocks and cares about the gui
(updating the gui, running subs connected to signals and such stuff).
But (in my opinion) when you run Gtk2->main_quit, you leave the main loop and
the script carries on just like a normal non-gui script.
Why is the gui still available when perl runs sleep?
And related to this question: How can I avoid this problem?
Thank you.
--Michael
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Are you sure it's "delete-event" and not 'delete_event' in
$window->signal_connect("delete-event" => sub { Gtk2->main_quit; 0;});
?
For some reason Perl gtk2 developers decided to rename foo-bar in "C" into
'foo_bar' in Perl.
I always curse - since most of the info is in "C" gtk2 documentation, so I
have to remember not to forget to do the additional transaltion for the code
to work.
--Sergei.
Applications From Scratch: http://appsfromscratch.berlios.de/
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]