From: Paul H. <pau...@gm...> - 2005-11-06 19:33:45
|
On 11/6/05, Mattia Barbon <mat...@li...> wrote: > > You should use > > $text->SetDefaultStyle( $textattr ); > > to change color: > > $textattr =3D Wx::TextAttr->new( Wx::Colour->new( 255, 15, 255 ) ); That doesn't seem to work, unless I'm missing something. The following test code should produce blue text on a green background, but instead the text still comes out black. My environment: ActivePerl v5.8.7 wxPerl 0.25 Windows XP SP2 #!/usr/bin/perl use strict; use Wx qw(:everything); package MyApp; use strict; use vars qw(@ISA); @ISA=3Dqw(Wx::App); sub OnInit { my($Class) =3D $_[0]; my($AppFrame) =3D MyFrame->new("Frame title", [10,10], [200,200]); $Class->SetTopWindow($AppFrame); $AppFrame->Show(1); 1; } package MyFrame; use strict; use vars qw(@ISA); @ISA=3Dqw(Wx::Frame); use Wx qw(:everything); sub new { my ($Class) =3D $_[0]; my ($Frame) =3D $Class->SUPER::new( undef, -1, $_[1], $_[2], $_[3]); my($Panel) =3D Wx::Panel->new($Frame, "Panel title", [0,0], [200,200]); my($RedAttr) =3D Wx::TextAttr->new(wxRED, wxGREEN); my($Text) =3D Wx::TextCtrl->new($Panel, -1, "", [0,0], [190,160], (wxTE_MULTILINE | wxTE_READONLY)); $Text->AppendText("This is plain text that goes on and on and wraps. "); my($TheRet) =3D $Text->SetDefaultStyle($RedAttr); if($TheRet) { die "The value from SetDefaultStyle was non-zero\n" }; $Text->AppendText("This should be in red on green."); return $Frame; } package main; my($App) =3D MyApp->new(); $App->MainLoop(); |