BTW I tried the example/psexample.pl that comes with the module
and it shows the same problem: It only prints out the "First line"
after it has finished sleeping.
Wx::Perl::ProcessStream->SetPollInterval( 10 );
did not help either.
Gabor
On Sun, Jul 20, 2008 at 10:17 AM, Gabor Szabo <[EMAIL PROTECTED]> wrote:
> On Thu, Jul 17, 2008 at 12:05 PM, Huub Peters <[EMAIL PROTECTED]> wrote:
>> Gabor Szabo wrote:
>>>
>>> So I am trying to write an editor using Wx.
>>> The basic editing is in place, now comes the really interesting part.
>>>
>>> I would like to run the script being edited and provide a way for the
>>> user to interact with it.
>>> Basicall I'd like to have a console window in my application where
>>> that is connected to
>>> the STD IN/OUT/ERR to an external application.
>>>
>>> Any recommendation how should I do that?
>>>
>>> Gabor
>>>
>>>
>>
>> I think you could use Wx::Perl::ProcessStream for that. I've never used
>> it but somebody ones showed me it's usage.
>> I think it was designed to help getting a GUI on top of a command line
>> program.
>
>
> I tried this and while it looks good actually I have not received any of the
> STDOUT events until the external program finished.
> In addition the lines I received lack the trailing newline from the
> actual output.
>
> The external program is just the following perl script:
>
> #!perl
> use strict;
> use warnings;
>
> my $n = 10;
> print "First line\n";
> print "Going to sleep $n seconds\n";
> sleep $n;
> print "Finished sleeping\n";
>
> and I am trying it on Ubuntu.
>
> The code I used:
>
> use base 'Wx::Frame';
>
> sub new {
> ...
> EVT_WXP_PROCESS_STREAM_STDOUT( $self, \&evt_process_stdout);
> }
>
> on_run {
> my ($self) = @_;
> $proc = Wx::Perl::ProcessStream->OpenProcess("$^X file.pl",
> 'MyName1', $self);
> }
> sub evt_process_stdout {
> my ($self, $event) = @_;
>
> $event->Skip(1);
> my $process = $event->GetProcess;
> my $line = $event->GetLine;
> $output->AppendText($line . "\n");
>
> return;
> }
>