um ... I like sweaters
#!/usr/bin/perl --
use strict;
use warnings;
use Wx qw/ :allclasses /;
my $frame = Wx::Frame->new( undef, -1, "statictext color change" );
$frame->{panel} = Wx::Panel->new( $frame );
$frame->{button} = Wx::Button->new( $frame->{panel} , -1, "Toggle", )
+;
$frame->{static} = Wx::StaticText->new( $frame->{panel}, -1, "I am co
+lorful" );
$frame->{sizer} = Wx::BoxSizer->new( Wx::wxVERTICAL() );
$frame->{panel}->SetSizer( $frame->{sizer} );
$frame->{sizer}->Add( $frame->{button} );
$frame->{sizer}->AddSpacer(100);
$frame->{sizer}->Add( $frame->{static} );
Wx::Event::EVT_BUTTON(
$frame,
$frame->{button},
\&button_click,
);
$frame->Show;
Wx::SimpleApp->new->MainLoop;
exit( 0 );
sub button_click {
my( $frame, $event ) = @_;
$frame->{hit}++;
my $static = $frame->{static};
my $color = $static->GetForegroundColour;
my $label = $static->GetLabel;
$label =~ s/ ## .*$//;
$label .= " ## ".localtime;
$static->SetLabel( $label );
if( $frame->{hit} % 2 ){
$static->SetForegroundColour( Wx::wxBLUE() );
} else {
$static->SetForegroundColour( Wx::wxRED() );
}
$static->Update;
}