Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Second background process is pausing the gui

by tybalt89 (Monsignor)
on Jun 12, 2020 at 14:55 UTC ( [id://11117985]=note: print w/replies, xml ) Need Help??


in reply to Second background process is pausing the gui

Here's how I'd do it.

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11117902 use warnings; use Tk; use Tk::IO; my $date = localtime(); my $mw = MainWindow->new; $mw->Button(-text => 'Start', -command => \&start, )->pack(-side => 'top', -fill => 'x'); $mw->Label(-textvariable => \$date, -fg => 'blue', )->pack(-side => 'top', -fill => 'x'); $mw->Button(-text => 'Exit', -command => sub {$mw->destroy}, )->pack(-side => 'bottom', -fill => 'x'); $_ = $mw->Text(-width => 10, -font => 14, )->pack(-side => 'left') for my( $one, $two ); $mw->repeat( 1000, sub { $date = localtime() } ); MainLoop; sub start { Tk::IO->new(-linecommand => sub { $one->insert(end => shift); $one->see('end');}, )->exec('for i in `seq 1 24` ; do sleep .5 ; echo $i ; done'); Tk::IO->new(-linecommand => sub { $two->insert(end => shift); $two->see('end');}, )->exec('for i in `seq 1 24` ; do sleep .7 ; echo $i ; done'); }

Note that the date keeps advancing while the text widgets are being filled in, indicating that the gui is still responding.

Replies are listed 'Best First'.
Re^2: Second background process is pausing the gui
by choroba (Cardinal) on Jun 12, 2020 at 15:57 UTC
    But if you replace one of the shell loops with find, it hangs again until the find finishes.
    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      I don't see that on my system.

      I did replace the second shell command with xterm -e htop and it did pop up a new xterm running htop while still filling in the first text widget, exactly as expected.

        You can watch it here (YouTube warning!)

        Interestingly, when I click into the area to be filled, the application responds, but it immediately gets stuck again.

        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11117985]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found