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("poetest.glade"); $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


In reply to POE(::Wheel::Run) hates me (the lib, not the guy {as far as I know}) by perlmonkey2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.