in reply to Perl:TK - standard output to text widget
And the sender script#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow; my $t = $mw->Text(-width => 80, -height => 25, -wrap => 'none'); $t->pack(-expand => 1); open(CHILD, "./read-stdout-piper 2>&1 |") or die "Can't open: $!"; $mw->fileevent(\*CHILD, 'readable', [\&fill_text_widget,$t]); MainLoop; sub fill_text_widget { my($widget) = @_; $_ = <CHILD>; if((defined $_) && ($_ > 5)){print chr(07)} $widget->insert('end', $_); $widget->yview('end'); }
!/usr/bin/perl $|++; for my $i ( 0 .. 10) { print $i, "\n"; sleep 1; } print "sleeping 5\n"; sleep 5; for my $i ( 0 .. 10) { print $i, "\n"; sleep 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl:TK - tail -f to text widget
by rehmanz (Novice) on Aug 16, 2010 at 23:41 UTC | |
by zentara (Cardinal) on Aug 17, 2010 at 12:57 UTC | |
by rehmanz (Novice) on Aug 17, 2010 at 20:11 UTC |