problem between perl-gtk2 and POE::Session

K

Krisztian VASAS

Hello...


I have some problem with perl-gtk2 and POE...


I'd like to write a small chat client in gtk2, but it doesn't want to
work as I'd like to.

If the program starts, 2 Gtk2::Window is opened (the main window and the
login window). After writing the nick and clicking to the OK button, the
connection should start. In the background I'm watching the OK button's
signal_connect("clicked") event, and I'd like to start a POE::Session
callback, but I can't see the $_[SESSION] variable in signal_connect().

The code is viewable here: http://nomorepasting.com/paste.php?pasteID=14758

The problem is in 200th line.

I could see, that the $var variable contains the $okbutton in akarmi()
function insted of the $_[SESSION].



Thanks for the early answer.

IroNiQ
 
R

Rocco Caputo

Hello...

I have some problem with perl-gtk2 and POE...

I'd like to write a small chat client in gtk2, but it doesn't want to
work as I'd like to.

If the program starts, 2 Gtk2::Window is opened (the main window and the
login window). After writing the nick and clicking to the OK button, the
connection should start. In the background I'm watching the OK button's
signal_connect("clicked") event, and I'd like to start a POE::Session
callback, but I can't see the $_[SESSION] variable in signal_connect().

The code is viewable here: http://nomorepasting.com/paste.php?pasteID=14758

The problem is in 200th line.

I could see, that the $var variable contains the $okbutton in akarmi()
function insted of the $_[SESSION].

Line 200 reads:

$okbutton->signal_connect("clicked", akarmi, $var);

You are using the return value of the call to akarmi() as your callback.
That is probably incorrect. Try this instead:

$okbutton->signal_connect("clicked", \&akarmi, $var);

Your code has other problems, too. For example, line 139:

my ($session, $heap) = shift;

$session is being initialized, but $heap remains undefined. It might be
better written as:

my ($session, $heap) = @_;

You may want to turn on C<use warnings> and C<use strict> to flush out
other problems, at least temporarily until you're more comfortable using
Perl.

for($i=0;$i<=$#szerver;$i++) {
my $menuitem = Gtk2::RadioMenuItem->new_with_label($group, $szerver[$i]);
$group = $menuitem->get_group;
$menu->append($menuitem);
$menuitem->show;
}

would be better written as:

foreach my $thingy (@szerver) {
my $menuitem = Gtk2::RadioMenuItem->new_with_label($group, $thingy);
$group = $menuitem->get_group;
$menu->append($menuitem);
$menuitem->show;
}

.... replacing $thingy with a better name, of course.

Finally, there is a problem in POE::Loop::Gtk2 on the CPAN. It was reported
last week, but I was at YAPC and couldn't get to it until today. We were able
to diagnose the problem today and send a patch to its author. I hope it will
be updated soon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top