Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

posting from POE to XUL

by rvosa (Curate)
on Feb 23, 2007 at 17:19 UTC ( #601781=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://601781]
Approved by Tanktalus
Front-paged by grinder
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (1)
As of 2020-12-06 01:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (65 votes). Check out past polls.

    Notices?