Question on Text Widget Update
I figured out a solution to this problem myself.
I used the filevent mechanism :
open TEXTF, "RunProg |";
$root->fileevent(TEXTF, 'readable', sub {
$tmpStr = <TEXTF>;
if (eof(TEXTF)) {
$root->fileevent(H, 'readable', '');
} else {
$logText->insert('end', $tmpStr);
$logText->yview('end');
}
} );
If I don't check for the eof in the subroutine, it seems to be
getting into some kind of loop...
By the way, where is the documentation for PERL/TK Fileevent stuff ??
I could get only the TK filevent docs.
Regards,
Krutibas Biswal
Mountain View,
CA
Quote:
> $logText = $root->Text (-borderwidth => '1', -height => '1', -width =>
> '1' );
> $textScroll = $root->Scrollbar( -borderwidth => '1',-relief => 'flat');
> $logText->configure(-yscrollcommand => ['set', $textScroll]);
> $textScroll->configure( -command => ['yview', $logText] );
> FORK: {
> if ( $child = fork ) {
> ## Parent Does nothing
> } elsif (defined $child) {
> open TEXTF, "RunProg |";
> while(<TEXTF>) {
> $logText->insert(end, $_);
> }
> close(TEXTF);
> } elsif ($! =~ /No more process/) {
> sleep 5;
> redo FORK;
> } else {
> die "Can't fork: $!\n";
> }
> }