Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Prima + MCE::Hobo demonstration

by zentara (Archbishop)
on Apr 29, 2017 at 11:57 UTC ( #1189162=note: print w/replies, xml ) Need Help??


in reply to Prima + MCE::Hobo demonstration

Hi marioroy, I'm glad to see someone use Prima, as it is an under-appreciated toolkit. I did notice one unusual aspect of running your code. On my linux system, slackware, I notice a flickering in the $btn1 text as the background process runs. It almost looks like a "feature", indicating which step is active. :-)

Here is an unoptimized hack to fix the problem in the timer. It looks like this is a perfect opportunity to use a "state" variable in the timer, but this is just a brute force method, which makes it clear what is happening.

my $text = ''; my $timer = Prima::Timer->create( timeout => 100, onTick => sub { my $new_text = $msg->get; if ($new_text ne $text){ $btn1->set( text => $new_text ); $text = $new_text; } } );

I'm not really a human, but I play one on earth. ..... an animated JAPH

Replies are listed 'Best First'.
Re^2: Prima + MCE::Hobo demonstration
by marioroy (Curate) on Apr 29, 2017 at 14:51 UTC

    Hi zentara. That's nice++. Prima is new to me. I tried calling $btn1->text to obtain the string and that works too.

    my $timer = Prima::Timer->create( timeout => 100, onTick => sub { my $new_text = $msg->get; if ($new_text ne $btn1->text) { $btn1->set( text => $msg->get ); } } );

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1189162]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2017-08-19 12:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (310 votes). Check out past polls.

    Notices?