Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, I have written perl/tk code to redirect from stdout to a widget. This widget is a text attached to a notebook attached to a frame. I am not getting the output as expected. I searched here and got the following code sample posted.
tie *STDOUT, 'Tk::Text', $tedit;
This does'nt seems to work for me as $tedit is text attached to a notebook. Please help. Thanks in advance

Replies are listed 'Best First'.
Re: Redirecting stdout
by Anonymous Monk on Oct 30, 2008 at 12:52 UTC
    show your code
      The code is as follows. I have edited a few lines.
      my $fright = $mw->Frame(-borderwidth=>3)->pack(-expand=>1, -side=>'lef +t', -fill=>'both'); my $fedit = $fright->Frame(-relief=>'sunken', -borderwidth=>5)->pack(-expand=>1, -side=>'top', -fill=>'both'); my $noteb = $fedit->NoteBook(-relief=>'raised', -background=>'skyblue' +)->pack(-expand=>1, -side=>'top', -fill=>'both'); my $nb1 = $noteb->add(1,-label=>"Stdout"); my $nb2 = $noteb->add(2,-label=>"View"); my $tedit = $nb1->Scrolled('Text', -scrollbars=>'oe')->pack(-expand=>1 +, -side=>'top', -fill=>'both'); $tedit->configure(-background=>'AliceBlue'); my $fileview = $nb2->Scrolled('ROText', -scrollbars=>'oe')->pack(-expa +nd=>1, -side=>'top', -fill=>'both'); $fileview->configure(-background=>'AliceBlue'); # Tie STDOUT to Text widget tie *STDOUT, 'Tk::Text', $tedit;