Hope this helps. It worked for me with AS Perl 5.8.4 and Windows XP.
use Tk; use Tk::ROText; use threads; use Thread::Queue; use strict; use warnings; my $mw = MainWindow->new(); my $t = $mw->Scrolled('ROText', -width => 40, -height=>20, -scrollbars +=>"e")->pack(); my $b = $mw->Button(-command => sub {threads->create(\&cook)}, -text=> +"Click")->pack(); my $q = Thread::Queue->new(); $t->after(1000, \&eat); MainLoop; sub eat { while (my $l = $q->dequeue_nb()) { $t->insert('end', $l); $t->update(); } $t->after(1, \&eat); } sub cook { print "thread created\n"; my ($in, $out); open($in, "e.pl |"); while (<$in>) { print "got $_"; $q->enqueue($_); } close($in); }
Here is the other process I used:
use strict; use warnings; for (1..10000000) { print $_, "\r\n"; }
In reply to Re: Trying to update a Tk:ROText widget as input is received from a backticked program
by pg
in thread Trying to update a Tk:ROText widget as input is received from a backticked program
by mears
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |