#!/usr/bin/perl -w # use strict; # use Encode::Unicode; use Tk; # open(H, "tail -f -n 25 $ARGV[0]|") or die "Nope: $!"; # open(STDOUT, "+> |") or die "Nope: $!"; # open STDOUT, '+<', \&test or die "Can't open STDOUT: $!"; $mw=MainWindow->new(); # create main window, and stretch it to fill screen minus a bit $mw->title("GRM Consulting Ltd. - GENESIS Optimisation Coupling Tool v1.0"); $mw->geometry("800x600+100+100"); my $t = $mw->Text(-width => 80, -height => 25, -wrap => 'none'); $t->pack(-expand => 1); # $mw->fileevent(\*STDOUT, 'readable', [\&fill_text_widget, $t]); $mw->update; test(); MainLoop; sub fill_text_widget { my($widget) = @_; my($stat, $data); $stat = sysread STDOUT, $data, 4096; die "sysread error: $!" unless defined $stat; $widget->insert('end', $data); $widget->yview('end'); } ## Test routine to simulate my main program execution sub test { for ($i=0; $i<3; $i++ ) { print "testline $i\n"; sleep 1; } $command="dir"; system("$command"); for ($i=0; $i<3; $i++ ) { print "testline1 $i\n"; sleep 1; } die; }