sdetweil has asked for the wisdom of the Perl Monks concerning the following question:
Wx::Event::EVT_COMMAND($panel, -1, $ID_OUR_EVENT, \&ourHandler +) sub ourHandler { my( $frame, $event ) = @_; my $text = $event->GetData; my $textvalue = Wx::GetTextFromUser($text, "some header", wxOK | w +xCANCEL,$self ) ; #---> what to do here with the dialog text. }
share (my $clientline); # in the main code, referenced here for clari +ty. my $event = new Wx::PlThreadEvent( -1, $ID_OUR_EVENT, $clien +tline); Wx::PostEvent($panel, $event );
local (*HIS_IN ,*HIS_OUT, *HIS_ERR, $childpid); use IPC::Open3; $childpid=open3( *HIS_IN, *HIS_OUT, *HIS_OUT,$command);
print HIS_IN $clientline . "\n";
use Wx::Perl::ProcessStream qw( :everything ); # setup the stream handlers EVT_WXP_PROCESS_STREAM_STDOUT ( wxperl_window, \&evt_process_stdout +_err ); EVT_WXP_PROCESS_STREAM_STDERR ( wxperl_window, \&evt_process_stdout +_err ); EVT_WXP_PROCESS_STREAM_EXIT ( wxperl_window, \&evt_process_exit + ); EVT_WXP_PROCESS_STREAM_MAXLINES ( wxperl_window, \&evt_process_maxlin +es ); the handlers (here both the childs stdout & sterr are handled in the s +ame handler) sub evt_process_stdout_err { my( $self, $event ) = @_; $event->Skip(1); my $process = $event->GetProcess; my $clientline = $event->GetLine; $clientline=~s/"//g; $clientline=~s/\s+$//g; # string off all quotes and trailing whitespace # show it in the test window $detailsInfo->AppendText("$clientline\n"); # if the output line ends with identified line end, then it is abou +t to be a prompt if ($clientline=~m/($specialeol)$/) { my $textvalue = Wx::GetTextFromUser($clientline, "pre exit prom +pt", "",$self) ; $process->WriteProcess("$textvalue\n"); } } sub evt_process_exit { my ($self, $event) = @_; $event->Skip(1); my $process = $event->GetProcess; my $line = $event->GetLine; my @buffers = @{ $process->GetStdOutBuffer }; my @errors = @{ $process->GetStdErrBuffer }; my $exitcode = $process->GetExitCode; $process->Destroy; } the startup (this replaces all the thread goo) my $proc1 = Wx::Perl::ProcessStream::Process->new($command, 's +omelabel', wxperl_window)->Run;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: threads, file handles and wxPerl
by zentara (Cardinal) on Feb 13, 2013 at 16:24 UTC | |
by sdetweil (Sexton) on Feb 13, 2013 at 17:02 UTC | |
by BrowserUk (Patriarch) on Feb 13, 2013 at 17:12 UTC | |
by sdetweil (Sexton) on Feb 13, 2013 at 17:27 UTC | |
by BrowserUk (Patriarch) on Feb 13, 2013 at 18:58 UTC | |
|
Re: threads, file handles and wxPerl
by bulk88 (Priest) on Feb 13, 2013 at 16:39 UTC | |
by sdetweil (Sexton) on Feb 13, 2013 at 17:23 UTC | |
by sdetweil (Sexton) on Feb 13, 2013 at 17:31 UTC | |
by stefbv (Priest) on Feb 13, 2013 at 18:22 UTC | |
by sdetweil (Sexton) on Feb 13, 2013 at 18:57 UTC | |
|
Re: threads, file handles and wxPerl
by zentara (Cardinal) on Feb 17, 2013 at 13:10 UTC |