how to redirect stdout to wx::textctrl? thanks

L

lsyx

Code:
##################
#!/usr/bin/perl
use strict;
use warnings;
use Wx;
use threads;
use threads::shared qw/shared_clone/;

package MyFrame;
use Wx qw(wxTE_MULTILINE);
use base qw/Wx::Frame/;

sub new
{
my ( $class, $frame, $title, $x, $y, $w, $h ) = @_;

my ($this) = $class->SUPER::new(
$frame, -1, $title,
Wx::point->new( $x, $y ),
Wx::Size->new( $w, $h ) );

my $notebook = Wx::Notebook->new( $this, -1 );
my $log = Wx::TextCtrl->new(
$notebook, -1, "test\n",
[ 10, 10 ],
[ 500, 300 ],
wxTE_MULTILINE
);

$this;
} ## end sub new

#}

#{
package MyApp;
use strict;
use base qw/Wx::App/;

sub OnInit
{
my ($this) = @_;

my ($frame) =
MyFrame->new( undef, "test", 50, 50, 540,
430 );

$frame->SetSizeHints( 500, 425 );

$frame->Show(1);
$this->SetTopWindow($frame);

1;
} ## end sub OnInit

package main;
my $gui = MyApp->new();

my $worker = threads->create( \&work );

$gui->MainLoop();

sub work {
print "abcdefgh\n";
}
##############
how to put
work() 's out text : abcdefgh
into
my $log = Wx::TextCtrl 's window ?

thanks for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top