Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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?

In reply to posting from POE to XUL by rvosa

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-25 16:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found