I am trying to output some text into a Text widget. The code I am using for
this is lifted directly from Mastering Perl/Tk (p180) so I won't list it
all here, but the pertinent code is along the lines of:
tie *STDOUT, ref $textWidget, $textWidget;
No problem. Except every time I run it, I get the error that Tk:TIEHANDLE
cannot be found. I made sure by reinstalling Tk - both via CPAN shell and
'manually' - and I still get the same error.
Is there something else I should be installing, as I am at a loss here. :\
Dela
Are you sure you have copied the code "as is"? i.e. I suspect you might have use
the Scrolled method, and doing so will return a Tk::Frame when getting the
reference. This will cause the error message you describe.
#### Working copy with Scrolled ####
use Tk;
use strict;
my $mw = new MainWindow;
my $text = $mw->Scrolled('Text',qw/-width 40 -height 10/)->pack;
my $realtext=$text->Subwidget('text');
tie *STDOUT, ref $realtext, $realtext;
$mw->Button(-text=>'PressMe',-command=>sub{print int rand(1000000),"\n"})->pack;
MainLoop;
##############################
--
Jack D.
Remove '__' from address if replying by e-mail.
> Are you sure you have copied the code "as is"? i.e. I suspect you might
> have use the Scrolled method, and doing so will return a Tk::Frame when
> getting the reference. This will cause the error message you describe.
<snip code>
What can I say? It was late, and I'm green.... ;)
That was it entirely. I forgot I was using Scrolled, not just a plain Text
widget. Fixed and running now.
Thanks again,
Dela
> Are you sure you have copied the code "as is"? i.e. I suspect you might
> have use the Scrolled method, and doing so will return a Tk::Frame when
> getting the reference. This will cause the error message you describe.
<snip code>
tie *STDOUT, ref $realtext, $realtext
with the Scrolled method or something similar? I need to create an script
that can insert text and update the scroll bars as needed. Also, I need
to re-direct output to the this window as well.
thanks,
Rob.
tie *STDOUT, ref $realtext, $realtext
with the Scrolled method or something similar? I need to create an script