Problems updating a label
- From: Vitor Peres <ruyven ig com br>
- To: gtk-perl-list gnome org
- Subject: Problems updating a label
- Date: 15 Sep 2003 11:17:10 -0300
Hello, people. I have recently subscribed, hoping my not so intriguing
doubts are cleared and to clear other people's as well.
I am new to Gtk-Perl, so what I want to ask is this: how can I update a
label periodically? A friend of mine, knowing GTK+, told me to read
about g_timeout_add... well, read I did, and I am not sure I quite get
the workings of it.
I want to pass control to a sub, so I can perform a series of
activities, and then return to main. The activities are supposed to be
going on in predefined intervals, retrieving a certain information,
updating the label and repeating everything after a certain period of
time.
I tried to implement it using what I did (didn't?) understand from
reading the API and C code, but I always get
*** unhandled exception in callback:
*** Undefined subroutine &main::1 called at smallerr.pl line 14.
*** ignoring at smallerr.pl line 14.
after the sub is called for the first time. I get the desired results,
however, when I write the sub directly into Glib::Timeout->add, but this
is far from ideal. I am intrigued by how Gtk->main() becomes undefined,
so your help will be appreciated. The error above refers to the sample
code below, but is just the same for everything I try...
---
#!/usr/bin/perl -w
use strict;
use Gtk2 '-init';
use Glib '-init';
my $window = Gtk2::Window->new();
my $lcall_label = Gtk2::Label->new('Retrieving data...');
$window->add($lcall_label);
Glib::Timeout->add(3000, &update_pcalls($lcall_label));
$window->show_all();
Gtk2->main();
sub update_pcalls {
my $llabel = shift;
my $date = time();
$llabel->set_text($date);
return 1;
}
---
Thanks in advance,
Vitor
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]