Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Problem with Gtk2 and POE

Reply
Thread Tools

Problem with Gtk2 and POE

 
 
Krisztian VASAS
Guest
Posts: n/a
 
      06-28-2004

Hello all...


I have a big problem with Gtk2 and POE (or I'm too stupid to the POE)...

Between the POE examples, there is a Gtk Interface (small counter)...
I've tried to rewrite it in Gtk2, but didn't want to work.

Neither the $kernel->yield("state_name"), nor the
$session->postback("state_name") works...

The Gtk2 interface starts, but if I press the button, nothing happens.
If I close the window, perl writes this:
"POE::Kernel's run() method was never called."

I can't understand this, because the first part of the script hasn't
changed:

POE::Session->create( inline_states =>
{
_start => \&ui_start,
ev_count => \&ui_count,
ev_clear => \&ui_clear,
});

But when I press the button, the signal_connect doesn't want to run the
$session->postback("ev_clear") command...

Can anyone tell me, why?


IroNiQ
--
Web: http://ironiq.hu
Email:
LinuxCounter: #331532
 
Reply With Quote
 
 
 
 
Rocco Caputo
Guest
Posts: n/a
 
      06-28-2004
On Mon, 28 Jun 2004 19:12:12 +0200, Krisztian VASAS wrote:
>
> Hello all...
>
>
> I have a big problem with Gtk2 and POE (or I'm too stupid to the POE)...
>
> Between the POE examples, there is a Gtk Interface (small counter)...
> I've tried to rewrite it in Gtk2, but didn't want to work.
>
> Neither the $kernel->yield("state_name"), nor the
> $session->postback("state_name") works...


Works here. The program I tested with is nearly the same as the one on
POE's wiki. I just changed all the "Gtk"s to "Gtk2". Here's a copy:

#!/usr/bin/perl

use warnings;
use strict;

use Gtk2;
use POE;

POE::Session->create(
inline_states => {
_start => \&ui_start,
ev_count => \&ui_count,
ev_clear => \&ui_clear,
}
);

$poe_kernel->run();
exit 0;

sub ui_start {
my ( $kernel, $session, $heap ) = @_[ KERNEL, SESSION, HEAP ];

$heap->{main_window} = Gtk2::Window->new("toplevel");
$kernel->signal_ui_destroy( $heap->{main_window} );

my $box = Gtk2::VBox->new( 0, 0 );
$heap->{main_window}->add($box);
$box->show();

my $label = Gtk2::Label->new("Counter");
$box->pack_start( $label, 1, 1, 0 );
$label->show();

$heap->{counter} = 0;
$heap->{counter_label} = Gtk2::Label->new( $heap->{counter} );
$box->pack_start( $heap->{counter_label}, 1, 1, 0 );
$heap->{counter_label}->show();

my $button = Gtk2::Button->new("Clear");
$button->signal_connect( "clicked", $session->postback("ev_clear") );
$box->pack_start( $button, 1, 1, 0 );
$button->show();

$heap->{main_window}->show();

$kernel->yield("ev_count");
}

sub ui_count {
my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
$heap->{counter_label}->set_text( ++$_[HEAP]->{counter} );
$kernel->yield("ev_count");
}

sub ui_clear {
$_[HEAP]->{counter} = 0;
}

__END__

--
Rocco Caputo - http://poe.perl.org/


 
Reply With Quote
 
 
 
 
Krisztian VASAS
Guest
Posts: n/a
 
      06-28-2004
Rocco Caputo wrote this on 2004-06-28 19:48:
> Works here. The program I tested with is nearly the same as the one on
> POE's wiki. I just changed all the "Gtk"s to "Gtk2". Here's a copy:


Problem solved...

Wasn't installed the POE::Loop::Gtk2...


IroNiQ
--
Web: http://ironiq.hu
Email:
LinuxCounter: #331532
 
Reply With Quote
 
Krisztian VASAS
Guest
Posts: n/a
 
      06-29-2004
> Rocco Caputo wrote this on 2004-06-28 19:48:
>
>> Works here. The program I tested with is nearly the same as the one on
>> POE's wiki. I just changed all the "Gtk"s to "Gtk2". Here's a copy:

>
>
> Problem solved...
>
> Wasn't installed the POE::Loop::Gtk2...


Well, now works quiet well, but I have another problem and I can't
decide what's the problem...

I write a small chat client... I use POE to handle the net connection
and the Gtk2 UI... The POE::Session starts the main window... If the
main window is ready, calls the login window...
If I miss calling the login window and connect to the server, the
program works good...
If I call the login window, the program gets a stop signal
(POE::Session->create( inline_states => _stop)...

I've tried to reduce the program to the smallest amount code that still
triggers the problem and looks like this is Gtk2's (?) fault.

Here's the code: http://www.nomorepasting.com/paste.php?pasteID=15366

Thanks...


IroNiQ
--
Web: http://ironiq.hu
Email:
LinuxCounter: #331532
 
Reply With Quote
 
Rocco Caputo
Guest
Posts: n/a
 
      06-30-2004
On Tue, 29 Jun 2004 22:15:17 +0200, Krisztian VASAS wrote:
>
> Well, now works quiet well, but I have another problem and I can't
> decide what's the problem...


[...]

> I've tried to reduce the program to the smallest amount code that still
> triggers the problem and looks like this is Gtk2's (?) fault.
>
> Here's the code: http://www.nomorepasting.com/paste.php?pasteID=15366


When I run that code, I get:

2) poerbook:~/projects/support% perl gtk2-client.perl
Bareword "menuitem_quit" not allowed while "strict subs" in use \
at gtk2-client.perl line 73.
BEGIN not safe after errors--compilation aborted \
at gtk2-client.perl line 243.

After I changed line 73 to be

$window->signal_connect("destroy", \&menuitem_quit );

I started getting these errors:

Gtk-WARNING **: gtk_item_factory_create_item(): Can't specify a \
callback on a branch: "/_File" at gtk2-client.perl line 85.
Gtk-WARNING **: gtk_item_factory_create_item(): Can't specify a \
callback on a branch: "/_Settings" at gtk2-client.perl line 85.
Gtk-WARNING **: gtk_item_factory_create_item(): Can't specify a \
callback on a branch: "/_Help" at gtk2-client.perl line 85.
Fontconfig error: Cannot load default config file
2 -> login (from gtk2-client.perl at 132)
2 -> _stop (from \
/Users/troc/projects/poe/poe/lib/POE/Resource/Sessions.pm at 492)

The Gtk-WARNING lines say you're not setting up @menu_items correctly.
Sure enough, they go away when I replace the 0 callbacks with undef.

The \&loginablak callback for "<control>N" should probably be
$session->postback("login") instead. The program doesn't immediately
exit when I change it here, but it also doesn't connect to a server when
I try that.

Line 203 reads

$session->postback("ar_conn")

You probably should add this to gui_start()

$kernel->alias_set("gui");

and then replace line 203 with

$poe_kernel->post("gui", "ar_conn");

.... and that makes the [Ok] button connect to the server.

I have placed an updated version of your script at
http://www.nomorepasting.com/paste.php?pasteID=15396

Have fun!

--
Rocco Caputo - http://poe.perl.org/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enhanced PoE on 3560-E and 3750-E Pandaeatsbamboo VOIP 0 04-03-2009 09:14 AM
Enhanced PoE on 3560-E and 3750-E Pandaeatsbamboo Cisco 0 04-03-2009 09:14 AM
An example of a device that uses PoE *and* runs at gigabits speed? Ramon F Herrera Cisco 8 07-31-2008 09:02 PM
Is it a gtk2 problem or Threads problem prameela Perl Misc 0 03-19-2006 04:28 AM
problem between perl-gtk2 and POE::Session Krisztian VASAS Perl Misc 1 06-24-2004 02:03 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57