http://qs321.pair.com?node_id=601781

rvosa has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

I am trying to write an app that follows a changing log file and posts the results back to a XUL::Node TextBox widget. To keep things from blocking, I figured POE would be the way to follow the log. So far, everything seems to be working in that: 1) the widgets show up in firefox; 2) log changes are printed to STDOUT while the XUL app is doing its own thing. Unfortunately, posting the log changes to the text widget doesn't seem to work.

In a simple form, this is what I'm trying to do:
BEGIN { $ENV{'DYLD_LIBRARY_PATH'} = '/Users/rvosa/CIPRES-and-deps/cipres-1 +.0.1/build/lib/perl/lib/ext/lib:' . $ENV{'DYLD_LIBRARY_PATH'}; use lib '/Users/rvosa/CIPRES-and-deps/cipres-1.0.1/build/lib/perl/ +lib'; } use strict; use POE qw(Component::XUL Wheel::FollowTail); use XUL::Node; use XUL::Node::Application; use base 'XUL::Node::Application'; my $ROOT = '/Users/rvosa/CIPRES-and-deps/cipres-1.0.1/build/lib/per +l/lib/xul-node/'; my $PORT = 8077; my $LOGFILE = $ENV{'HOME'} . '/registry.log'; POE::Session->create( 'inline_states' => { '_start' => sub { my $kernel = $_[KERNEL]; my $heap = $_[HEAP]; my $session = $_[SESSION]; POE::Component::XUL->spawn( { 'port' => $PORT, 'root' => $ROOT, 'apps' => { 'Test' => sub { return Window( $heap->{'tb'} = TextBox(), ); } }, } ); $heap->{'wheel'} = POE::Wheel::FollowTail->new( 'Filename' => $LOGFILE, 'InputEvent' => 'got_line', 'SeekBack' => 1024, ); $heap->{'first'} = 0; }, 'got_line' => sub { my $heap = $_[HEAP]; my $tb = $heap->{'tb'}; my $msg = $_[ARG0]; if ( $heap->{'first'}++ && defined $tb ) { # THIS DOESN'T WORK, NO UPDATE IN WIDGET $tb->value( $msg ); print "POSTED TO TEXTBOX: $msg\n"; } elsif ( $heap->{'first'}++ && ! defined $tb ) { print "NO TEXTBOX: $msg\n"; } }, }, ); $poe_kernel->run();
...but the end result is that I do get, at first, logging messages prefixed with "NO TEXTBOX: " printed to STDOUT, subsequently, when the XUL widgets are instantiated, messages with a "POSTED TO TEXTBOX: " posted to STDOUT, but nothing shows up in the actual textbox.

I am not very experienced with either XUL or POE, but I've been trying to grasp what's going on. The thing that has me stumped is the fact that the textbox widget both when created and when pulled off the heap in the log reading callback have the same memory address (I half and half expected a copy was made somewhere deep in the POE bowels) so I don't see why the ->value() method call doesn't do what it always does, i.e. display the argument inside the widget.

Any hints?

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.