refresh+update on macosx
Erik Colson <[email protected]>
| Newsgroups | gmane.comp.lang.perl.wxperl |
|---|---|
| Message-ID | <[email protected]> |
Hi, The code in the attached file is working nicely on Windows XP. i.e. when clicking on 'add text' it adds a line to the textctrl each second. On Macosx the same code only shows the added 30 lines once execution hits the event loop. Any idea why this happens ? best -- erik colson
ww.pl
(application/octet-stream, 1.6 KB)
package main;
use Modern::Perl;
WxMultiLineCtrl->new()->MainLoop();
package WxMultiLineCtrl;
use base qw(Wx::App);
use Wx qw (wxVERTICAL wxTOP wxGROW wxHORIZONTAL wxTE_MULTILINE
wxFIXED_MINSIZE wxLEFT wxTE_READONLY );
use Wx::Event qw( EVT_BUTTON );
sub OnInit {
my $app = shift;
my $title = 'MultiLine Wx Text Control';
my $frame = Wx::Frame->new( undef, -1, $title, [ -1, -1 ], [ 640, 280 ] );
my $p = Wx::Panel->new( $frame, -1 );
my $v0 = Wx::BoxSizer->new(wxVERTICAL);
my $h1 = Wx::BoxSizer->new(wxHORIZONTAL);
my $h2 = Wx::BoxSizer->new(wxHORIZONTAL);
my $term = Wx::TextCtrl->new( $p, -1, "$title\n",
[ -1, -1 ],
[ 600, 200 ],
wxTE_MULTILINE|wxTE_READONLY );
my $cancelBtn = Wx::Button->new( $p, -1, "cancel", [ -1, -1 ], [ -1, -1 ] );
my $addTxtBtn =
Wx::Button->new( $p, -1, "add text", [ -1, -1 ], [ -1, -1 ] );
$p->{TERM} = $term;
EVT_BUTTON( $p, $cancelBtn, \&cancel );
EVT_BUTTON( $p, $addTxtBtn, \&addTxt );
$v0->Add( $h1, 1, wxLEFT );
$v0->Add( $h2, 1, wxLEFT );
$h1->Add( $term, 1, wxTOP | wxGROW, 5 );
$h2->Add( $cancelBtn, 1, wxTOP | wxFIXED_MINSIZE, 5 );
$h2->Add( $addTxtBtn, 1, wxTOP | wxFIXED_MINSIZE, 5 );
$p->SetSizer($v0);
$p->SetAutoLayout(1);
$app->SetTopWindow($frame);
$frame->Show(1);
}
sub addTxt { my $p=shift; foreach (1..30) { $p->{TERM}->AppendText("another line $_\n"); $p->{TERM}->Refresh;$p->Update; print "$_\n"; sleep 1;} }
sub cancel { exit; }