Hi,

when writing a program that uses Gtk3, how can I make it so that the
program does something at regular time intervals?

Once Gtk3::main has been called, the program appears to be stuck in a
loop or something and does nothing but Gtk3 stuff.


I want to use something like Gtk3 to have the program display some
information in a window.  The program does something at regular
intervals, and after it has done its work, the information in the window
needs to be updated.

There doesn´t appear to be any Gtk3 function that would allow to set
some kind of timer which calls a function in regular intervals.


Here´s an example taken from http://search.cpan.org/dist/Gtk3/lib/Gtk3.pm:


#!/usr/bin/perl

use strict;
use Gtk3 -init;

my $window = Gtk3::Window->new ('toplevel');
my $button = Gtk3::Button->new ('Quit');

my $iwindow = Gtk3::Window->new ('toplevel');
my $image = Gtk3::Image->new_from_file('image.png');
$iwindow->add($image);
$iwindow->show_all;

$button->signal_connect(clicked => sub { Gtk3::main_quit });
$window->add($button);
$window->show_all;

my $bwindow = Gtk3::Window->new ('toplevel');
$bwindow->set_title('bar');
my $bar = Gtk3::Statusbar->new();
$bwindow->add($bar);
$bar->push($bar->get_context_id('bar'), 'image.png');
$bwindow->show_all;


Gtk3::main;

print "test\n";


I´ve added a window that displays an image and a status bar.  The
program doesn´t do anything but the Gtk3 stuff.  I need it to do what
it´s supposed to do and then update the information in the status bar
(or whatever widget is better suited for that) and, perhaps, the image
(once I figured out how to get something like a draw area).

Somehow suspending Gtk3::main to allow the program to do its work
doesn´t seem like a good idea because all the GUI would probably become
unresponsive.

Perhaps I need to fork the "worker program", but then how would it tell
the "display program" what information to display?

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to