CPAN::Forum
Tcl-Tk - Tie STDOUT to a text widget
| Posted on Thu Oct 11 03:05:31 2007 by jasonp |
| Tie STDOUT to a text widget |
|
I have an existing Perl application that I am being asked to write a GUI for.
My plan is to use vtcl with Tcl::Tk and its going fairly well at this point. (See http://vkonovalov.ru/vtcl-usage/Using_vtcl_for_creating_Tcl-Tk_GUI_for_Perl.html )
The existing application already outputs transcript messages to STDOUT and STDERR. They come from many places in the code and converting them all into text widget insets will be tedious. I notice that in Perl's Tk module you can tie STDOUT to a text widget. Its nice.
use strict;
use Tk;
my $mw = MainWindow->new;
my $text = $mw->Text(qw/ -width 40 -height 10/)->pack;
tie *STDOUT, ref $text, $text;
print "Hello World";
MainLoop;
I dont think I can do this with Tcl::Tk because I think its the Tk modules special support for the TIEHANDLE that allows it.
Any suggestions on how I might do it?
a) Maybe in raw TCL, somehow capturing the PERL STOUT/STDEER streams?
b) Maybe intermixing Tk module with Tcl::Tk, using Tk for that one Text widget. But how would I connect my Tk text widget to the TCL gui?
|
| Write a response |
(1)
]