Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
about a month ago I've found a very nifty and simple client/server application example which is written in Perl+Gtk2. Unfortunately it's pretty outdated and I just can't start it.
First I had to change Gtk2->init(\@ARGV); to Gtk2::init(\@ARGV); and I came a bit further.
I played for hours to get over this hurdle. But right now I'm stuck with the GSignal thing.
In fact this is the part, which won't work for me:

Gtk2::GSignal->connect($button_poll,"clicked", \&poll_host); Gtk2::GSignal->connect($button_exit,"clicked", \&exit_app);

When I start the app, following error message appears:
$ ./client-gui.pl Can't locate object method "connect" via package "Gtk2::GSignal" (perh +aps you forgot to load "Gtk2::GSignal"?) at ./client-gui.pl line 91. $
When I load "Gtk2::GSignal", then I get this message:
$ ./client-gui.pl Can't locate Gtk2/GSignal.pm in @INC (@INC contains: /usr/local/lib/pe +rl5/5.10.1/BSDPAN /usr/local/lib/perl5/site_perl/5.10.1/mach /usr/loc +al/lib/perl5/site_perl/5.10.1 /usr/local/lib/perl5/5.10.1/mach /usr/l +ocal/lib/perl5/5.10.1 .) at ./client-gui.pl line 13. BEGIN failed--compilation aborted at ./client-gui.pl line 13. $
Now I don't know how to install Gtk2/GSignal. Simply issuing "install Gtk2::GSignal" or "install GSignal" in cpan shell won't work.
It seems that this GSignal thing doesn't even exist.
Here's the link to the full client-gui.pl source code:
http://techrepublic.com.com/html/tr/sidebars/1058741-4.html
Can anybody help me with this?

Kind regards,
A~M

Replies are listed 'Best First'.
Re: Perl+Gtk2 Gtk2::GSignal
by jethro (Monsignor) on Apr 20, 2010 at 01:04 UTC

    I don't know a thing about Gtk2, but the example in the gtk2 perldoc has a good fit for your lines, provided your $button_poll and $button_exit are simply button objects.

    my $button = Gtk2::Button->new ('Quit'); $button->signal_connect (clicked => sub { Gtk2->main_quit });

    So your first line should probably look like this:

    # old line Gtk2::GSignal->connect($button_poll,"clicked", \&poll_host) +; $button_poll->signal_connect (clicked => \&poll_host);
      Thank you jethro.
      After some minor adjusting of the code the issues with the GSignal thing disappeared.

      Regards,
      A~M