Subject: | increasing ghost events, if more than one wxapp |
create wxapp, destroy wxapp
create second wxApp, stdout/stdout is repeated two times
create third wxApp, stdout/stdout is repeated three times
create fourth wxApp, stdout/stdout is repeated four times
....
not good :)
not good :)
not good :)
not good :)
Subject: | wxProcessStreamEcho.pl |
#!/usr/bin/perl --
use strict;
use warnings;
use Wx 0.99 ;
Main( @ARGV );
exit( 0 );
sub Main {
Fain() for 1 .. 6;
}
sub Fain {
my $app = Wx::SimpleApp->new;
my $frame = Wx::Frame->new(undef,-1,"", [21,21+ rand(5)] );
my $text = Wx::TextCtrl->new(
$frame,
-1,
"",
Wx::wxDefaultPosition(),
Wx::wxDefaultSize(),
Wx::wxTE_MULTILINE() |
Wx::wxTE_READONLY() |
Wx::wxHSCROLL() |
Wx::wxNO_BORDER()
);
Wx::Log::SetActiveTarget( Wx::LogTextCtrl->new( $text ) );
$frame->Show(1);
$app->SetTopWindow($frame);
$app->{frame} = $frame;
$app->{text} = $text;
use Wx::Perl::ProcessStream qw( :everything );
EVT_WXP_PROCESS_STREAM_STDERR ( $app, \&evt_process_stderr_stdout );
EVT_WXP_PROCESS_STREAM_STDOUT ( $app, \&evt_process_stderr_stdout );
EVT_WXP_PROCESS_STREAM_EXIT ( $app, \&evt_process_exit );
{
my $cmd = ['perl','-le',
' $f=gmtime; print $f; warn $f; warn $$; ' ];
my $process = Wx::Perl::ProcessStream::Process->new(
$cmd,
join(' ','[',@$cmd,']'),
$app,
)->Run;
}
$app->MainLoop;
}
use Wx::Perl::Carp qw' warn ';
sub evt_process_exit {
my ($self, $event) = @_;
$event->Skip(1);
my $exitcode = '';
my $procname = '';
eval {
$exitcode = $event->GetProcess->GetExitCode();
$procname = $event->GetProcess->GetProcessName();
$event->GetProcess->Destroy;
1;
} or warn $@;
my $apptext = qq(EXIT: $procname: $exitcode\n);
$self->{text}->AppendText($apptext);
return;
}
sub evt_process_stderr_stdout {
my ($self, $event) = @_;
$event->Skip(1); # allow event to be processed by further handlers
my $procname = $event->GetProcess->GetProcessName();
my $line = $event->GetLine;
my $apptext = '';
my @stdout = @{ $event->GetProcess->GetStdOutBuffer };
my @stderr = @{ $event->GetProcess->GetStdErrBuffer };
$apptext .= qq($line\n);
$self->{text}->AppendText($apptext);
return;
}