Hello Monks,

I'm trying to tie STDOUT to a Tkx Text widget and all attempts fail. The list of what I've tried would fill a page of dense text. Here is what works and also what does not, and the 'does not' is documented everywhere online exactly as I've expressed it, including in "Mastering Perl/Tk", pg 180. I'd perfer to use ROText in this case to simulate what one sees at the command line when running a non-Gui Perl program.

What works, perfectly, and renders correctly, simplified:

use warnings; use strict; use v5.38; use Tkx qw(MainLoop combobox grid); use Tkx::ROText; ... my $text = Tkx::tk__text(".text",); my $text1 = $mw->new_tkx_ROText();

What does not work, obviously not both together, but either/or:

tie *STDOUT, ref $text, $text; tie *STDOUT, 'Tkx::ROText', $text1; Can't locate object method "TIEHANDLE" via package "main" at GCGuiQuer +y.pl line 31.

Any suggestions? I use Tkx, not Tk, because Tk fails to recognize font properties -underline and -overstrike whereas using named fonts in comparable Tkx constructions works correctly.

Thanks for your help.


In reply to tie *STDOUT fails in Tkx by perlboy_emeritus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.