in reply to Re^2: Perl:TK - tail -f to text widget
in thread Perl:TK - standard output to text widget
Look at this. You could open multiple IPC connected filehandles, watch them with multiple fileevents, and insert the output into the same text widget, with different colored text.
#!/usr/bin/perl use strict; use Tk; use IO::Handle; my $H=IO::Handle->new; open($H,"tail -f -n 50 z.txt |") or die $!; my $main = MainWindow->new; my $t = $main-> Scrolled('Text', -wrap=>'none')->pack(-expand=>1); $main->fileevent(\*$H,'readable',[\&fill,$t]); MainLoop; sub fill { my ($w) = @_; my $text; my $text =<$H>; $w->insert('end',$text); $w->yview('end'); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Perl:TK - tail -f to text widget
by rehmanz (Novice) on Aug 17, 2010 at 20:11 UTC |