Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

POE(::Wheel::Run) hates me (the lib, not the guy {as far as I know})

by perlmonkey2 (Beadle)
on Jun 17, 2008 at 18:32 UTC ( #692568=perlquestion: print w/replies, xml ) Need Help??
perlmonkey2 has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks. My question to those masters of Perlish wisdom pertains to POE::Wheel::Run on Win32. The code I'm posting is being ran on Win32 and seems to run up to the point where the parents event handler for the child's IO should trigger. Nothing happens. Well first let me explain what should happen. You start the app, a small widget pops up. You click the button, and the widget's label lets you know it worked, then a Wheel::Run is spun off which immediately prints to STDOUT, which should cause the stdout event handler to be triggered (which is what doesn't happen). So any clues/help would be greatly appreciated.
#!/usr/bin/perl -w use strict; use FileHandle; use Data::Dumper; use Gtk2 -init; use Gtk2::GladeXML; use POE::Kernel { loop => "Glib" }; use POE::Session; use POE::Wheel::Run; use POE::Filter::Line; use IO::Handle; autoflush STDOUT 1; autoflush STDIN 1; POE::Session->create( inline_states => { stdout => \&stdout, ev_clear => \&ev_clear, _start => \&_start, stderr =>\&stderr, error =>\&error, close =>\&close, } )->option(trace => 1,debug => 1); POE::Kernel->run(); exit(0); sub _start{ my ($session,$heap) = @_[ SESSION, HEAP]; $heap->{'gtk'} = Gtk2::GladeXML->new(""); $heap->{'gtk'}->get_widget('button1')->signal_connect( ( "clicked", $session->postback("ev_clear")) ); $heap->{'gtk'}->get_widget('mainwindow')->show_all; } sub ev_clear{ my ($session,$heap) = @_[SESSION,HEAP]; $heap->{'gtk'}->get_widget('label1')->set_text('worked'); $heap->{worker} = POE::Wheel::Run->new( Program => sub{ print "hello\r\n"; #my $line = <>; #print ">>$line<<\r"; my $io = new IO::Handle; if ($io->fdopen(fileno(STDOUT),"w")) { $io->print("It works\n"); } $io->close(); }, StdoutEvent => 'stdout', # Received data from the child +'s STDOUT. StderrEvent => 'stderr', # Received data from the child +'s STDOUT. ErrorEvent => 'error', CloseEvent => 'close', StdioFilter => POE::Filter::Line->new(), ); } sub stdout{ my ($arg,$heap) = @_[10,HEAP]; my $io = new IO::Handle; if ($io->fdopen(fileno(STDIN),"r")) { print $io->getline; $io->close; } print $arg,"\n\n\r"; $heap->{worker}->put("word yo\r"); } sub close{ print "child closed\n"; } sub error{ print "Just an Error\n"; } sub stderr{ my ($arg,$heap) = @_[10,HEAP]; print "Error $arg\n"; } __END__

20080618 Janitored by Corion: Restored node content

  • Comment on POE(::Wheel::Run) hates me (the lib, not the guy {as far as I know})
  • Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://692568]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2016-10-25 03:17 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (313 votes). Check out past polls.