Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tk::TIEHANDLE Errors

16 views
Skip to first unread message

Dela Lovecraft

unread,
Jun 27, 2003, 10:25:16 PM6/27/03
to
Dear All,

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

Jack D.

unread,
Jun 28, 2003, 12:41:30 AM6/28/03
to
"Dela Lovecraft" <dlove...@remove.this.to.email.me.breathe.com> wrote in
message news:u46La.945$sh4.1...@newsfep2-win.server.ntli.net...

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.


Dela Lovecraft

unread,
Jun 28, 2003, 8:29:20 AM6/28/03
to
Jack D. wrote:

> 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

Dela Lovecraft

unread,
Jun 28, 2003, 8:29:20 AM6/28/03
to
Jack D. wrote:

> 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>

roba

unread,
Oct 6, 2004, 2:38:06 PM10/6/04
to
Is there a way to use

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.

roba

unread,
Oct 6, 2004, 2:38:25 PM10/6/04
to
Is there a way to use

tie *STDOUT, ref $realtext, $realtext

with the Scrolled method or something similar? I need to create an script

roba

unread,
Oct 6, 2004, 9:02:11 PM10/6/04
to
Never mind, I found a way to do it with the Advertise and Subwidget
methods. By advertising the Scrolled method, and the deriving the
Scrolled widget's parent, aka Text, by way of Subwidget, you can re-direct
the print and printf to the Scrolled window.

er.muk...@gmail.com

unread,
Oct 9, 2017, 5:16:18 AM10/9/17
to
On Saturday, June 28, 2003 at 7:55:16 AM UTC+5:30, Dela Lovecraft wrote:
> Dear All,
>
> 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:
Any example or snippet will be appreciated.

Thanks,
Mukesh
0 new messages