Here is another example which uses IPC::Open3, the sender test script is below.
#!/usr/bin/perl use warnings; use strict; use IPC::Open3; use Tk; use Tk::ProgressBar; my $mw = new MainWindow; $mw->geometry("600x400"); my $tframe = $mw->Frame()->pack(); my $count = 0; my $l1 = $tframe->Label(-text => '%', -bg => 'black', -fg => 'green', )->pack(-side => 'left'); my $l2 = $tframe->Label( -text => $count, #-textvariable => \$count, -bg => 'black', -fg => 'green', -width => 3, )->pack(-side => 'left'); my $p = $tframe->ProgressBar( -troughcolor => 'black', -fg => 'lightgreen', -blocks => 1, -width => 20, -length => 200, -from => 0, -to => 100, -variable => \$count, )->pack(-side =>'right'); my $tout = $mw->Scrolled( 'Text', -foreground => 'white', -background => 'black', -width => 80, -height => 20, )->pack; $tout->tagConfigure( 'red', -foreground => 'red' ); my $pid = open3( 0, \*OUT, \*ERR, "STDERR_STDOUT-IPC3-sender" ); #the 0 is for ignoring \*IN (STDIN) $mw->fileevent( \*OUT, 'readable', \&write_out ); $mw->fileevent( \*ERR, 'readable', \&write_err ); MainLoop; ############################################################# sub write_out { $count = <OUT>; chomp $count; # use Encode; # eval $count; #prevents raw unicode, you may not need it # print "$count\n"; $l2->configure('-text'=> $count); $tout->insert( "end", "$count\n" ); $tout->see("end"); } #################################################### sub write_err { my $str = <ERR>; $tout->insert( "end", "\t$str", 'red' ); $tout->see("end"); } __END__
and the test script "STDERR_STDOUT-IPC3-sender"
#!/usr/bin/perl use warnings; use strict; $| = 1; my $count = 0; while(1){ $count++; print "$count\n"; warn "\tuh oh warning $count\n"; #send something to stderr sleep 1; }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re: how to display output of a process in text widget in real time by zentara
in thread how to display output of a process in text widget in real time by perlnu

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.