problem between perl-gtk2 and POE::Session

Discussion in 'Perl Misc' started by Krisztian VASAS, Jun 21, 2004.

  1. 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
    --
    Web: http://ironiq.hu
    Email:
    LinuxCounter: #331532
    Krisztian VASAS, Jun 21, 2004
    #1
    1. Advertising

  2. Krisztian VASAS

    Rocco Caputo Guest

    On Mon, 21 Jun 2004 12:10:27 +0200, Krisztian VASAS wrote:
    >
    > 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.

    --
    Rocco Caputo - - http://poe.perl.org/
    Rocco Caputo, Jun 24, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Krisztian VASAS

    Problem with Gtk2 and POE

    Krisztian VASAS, Jun 28, 2004, in forum: Perl Misc
    Replies:
    4
    Views:
    113
    Rocco Caputo
    Jun 30, 2004
  2. Theo James

    POE and Port Redirection

    Theo James, Sep 18, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    135
    news.hinet.net
    Sep 20, 2004
  3. gavino
    Replies:
    0
    Views:
    114
    gavino
    Aug 11, 2006
  4. Kurt M. Weber

    POE::Component::IRC::State and nick changes

    Kurt M. Weber, Nov 9, 2007, in forum: Perl Misc
    Replies:
    0
    Views:
    84
    Kurt M. Weber
    Nov 9, 2007
  5. Mpapec

    POE and SOAP

    Mpapec, Mar 14, 2008, in forum: Perl Misc
    Replies:
    0
    Views:
    120
    Mpapec
    Mar 14, 2008
Loading...

Share This Page