rvosa has asked for the wisdom of the Perl Monks concerning the following question:
So the idea in the code above is the following: anything printed to STDOUT later on in the program should appear in the text widget. Lo and behold, that works, except for what I assume is a buffering issue.# a frame in my Tk main window my $frame = $mw->Frame; # a text widget with attached scrollbars in my frame my $OutputText = $frame->Scrolled('Text', -height => '50', -width => '150', -scrollbars => 'osoe' ); # pack frame and text widget $frame->pack(qw/-side left -fill y/); $OutputText->pack(qw/-side bottom -fill both -expand 1/); # here I try to tie STDOUT to the text widget my $widget = $OutputText->Subwidget("text"); tie *STDOUT, ref $widget, $widget;
I get ten lines of "foo" after 100 seconds on my text widget, while I get a "foo" every 10 seconds on STDOUT.for ( 1..10 ) { sleep 10; print "foo\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk::Text and buffering, I think
by zentara (Cardinal) on May 12, 2005 at 10:49 UTC | |
|
Re: Tk::Text and buffering, I think
by polettix (Vicar) on May 12, 2005 at 10:49 UTC | |
by rvosa (Curate) on May 12, 2005 at 11:15 UTC |