Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^5: Can GTK3 be driven externally?

by Anonymous Monk
on Feb 05, 2020 at 23:15 UTC ( #11112465=note: print w/replies, xml ) Need Help??


in reply to Re^4: Can GTK3 be driven externally?
in thread Can GTK3 be driven externally?

Hi

Well, i only have gtk2 and I got

GLib-GObject-WARNING **: invalid (NULL) pointer instance GLib-GObject-CRITICAL **: g_signal_connect_data: assertion `G_TYPE_CHE +CK_INSTANCE (instance)' failed ... Can't locate object method "timeout_add" via package "Gtk2" ... Usage: Gtk2::main(class)

Checking around my harddisk i see

site\lib\Gtk2\api.pod 260:=item gtk_timeout_add => Glib::Timeout->add 262:=item gtk_timeout_remove => Glib::Source->remove

Gtk2::api

So this is what finally works, you should try swapping Gtk2/Gtk3 and see if it works for you :)

#!/usr/bin/perl -- use strict; use warnings; # use Gtk2; use Gtk2 -init; my $window = Gtk2::Window->new ('toplevel'); my $button = Gtk2::Button->new ('Quit'); $button->signal_connect (clicked => sub { Gtk2::main_quit }); $window->add ($button); $window->show_all; my $data = 'data'; # my $id = Gtk2->timeout_add(1000, \&handler, $data); my $id = Glib::Timeout->add(1000, \&handler, $data); Gtk2->main; sub handler { my ($data) = @_; print "timed out ... @_\n"; # return 1 if you want the handler to be called again later # return 0 to stop the handler from being called again return 1; } __END__

https://grep.metacpan.org/search?qd=Gtk2&source=metacpan&q=Timeout

https://metacpan.org/source/XAOC/Gtk2-1.24993/examples/timeouttest.pl

https://metacpan.org/pod/Gtk3#Porting-from-Gtk2-to-Gtk3

https://wiki.gnome.org/Projects/GTK-Perl/Recipes

http://gtk2-perl.sourceforge.net/doc/

https://github.com/dave-theunsub/gtk3-perl-demos

Replies are listed 'Best First'.
Re^6: Can GTK3 be driven externally?
by holandes777 (Scribe) on Feb 08, 2020 at 21:03 UTC
    It runs properly when changing Gtk2 to Gtk3, thank you!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11112465]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2020-10-26 16:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (252 votes). Check out past polls.

    Notices?