Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Win32::GUI, GUI::Loft and redirecting console output

by maskull (Novice)
on Oct 17, 2012 at 07:53 UTC ( #999476=perlquestion: print w/ replies, xml ) Need Help??
maskull has asked for the wisdom of the Perl Monks concerning the following question:

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.

Comment on Win32::GUI, GUI::Loft and redirecting console output
Select or Download Code
Re: Win32::GUI, GUI::Loft and redirecting console output
by Anonymous Monk on Oct 17, 2012 at 08:17 UTC
      That works -- thanks -- but what about the output from external programs I mentioned (pscp.exe) that I run with backticks? Also noticed that running "make_path($dir, 1)" from File::Path seems to crash the program.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://999476]
Approved by kcott
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2015-07-04 14:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls