Hello, I'm having a problem tying Windows console output (stdout, stderr, etc.) to my GUI textfield. My GUI is built with The GUI Loft and looks like so: http://dl.dropbox.com/u/9272296/gui.jpg Currently I am using the below trick to get console printouts to my bottom output window:
package Tie::Textfield; sub TIEHANDLE { my ($class, $control) = @_; bless { control => $control }, $class; } sub PRINT { my ($self, $text) = @_; $self->{'control'}->{'-text'} .= $text; }
I click the button to start the script once all 4 inputs are there.
sub ::btnButton1_Click { defined(my $win = $Win32::GUI::Loft::window{main}) or return(1); # the main script action goes here return(1); } ############################################## my $fileWindow = "test.gld"; my $objDesign = Win32::GUI::Loft::Design->newLoad($fileWindow) or die("Could not open window file ($fileWindow)"); $main = $objDesign->buildWindow() or die("Could not build window ($fil +eWindow)"); ############################################## tie *STDOUT, 'Tie::Textfield', $main->tfoutput; $main->Show(); Win32::GUI::Dialog();
It works fine but the actual output appears only after the whole script has completed and for the duration of it the button is inactive -- which is the behavior I kind of expected but not the behavior I want. I would like the output appear real time, line by line, like in an actual console window. Plus, I am going to use some external commandline programs like pscp.exe and would want the output from those as well. I'll be grateful for your thoughts on this.

In reply to Win32::GUI, GUI::Loft and redirecting console output by maskull

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.