blocking code after main loop
- From: Michael Hartmann <michael hartmann as-netz de>
- To: gtk-perl-list gnome org
- Subject: blocking code after main loop
- Date: Mon, 9 Oct 2006 19:57:40 +0200
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]