Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Perl:TK - standard output to text widget

by bbfu (Curate)
on Feb 27, 2004 at 21:25 UTC ( [id://332392]=note: print w/replies, xml ) Need Help??


in reply to Perl:TK - standard output to text widget

You can tie STDOUT to a Tk::Text object to have anything printed in perl appear in the text widget. This doesn't handle input, of course, nor does it work with any external programs you might call (for those, see the previous suggestions).

#!/usr/bin/winperl use warnings; use strict; use Tk; my $mw = MainWindow->new(); my $tx = $mw->Text()->pack(); tie *STDOUT, 'Tk::Text', $tx; $mw->repeat(1000, \&tick); MainLoop; my $count; sub tick { ++$count; print "$count\n"; }

bbfu
Black flowers blossom
Fearless on my breath

Replies are listed 'Best First'.
Re: Re: Perl:TK - standard output to text widget
by crabbdean (Pilgrim) on Feb 28, 2004 at 09:12 UTC
    Man you are no less than a God!!! What a brilliant solution. Very clever. Something I didn't even consider. Works a treat. Now I just have to solve the other little myriad of problems and see if I can come up with a nice modular solution.

    Its getting closer bit by bit.

    Dean
      merlyn pointed out that this feature is undocumented. Thus, it might be subject to change, not 100% reliable, etc. I haven't personally used it much, so I can't vouch for its reliability, either. If you have to use it in production code, you should keep a good test suite that you can re-run after every update.

      bbfu
      Black flowers blossom
      Fearless on my breath

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://332392]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found