Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Changing font colour in a Wx StaticText or Button

by beech (Parson)
on Aug 29, 2016 at 01:52 UTC ( [id://1170646]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Changing font colour in a Wx StaticText or Button
in thread Changing font colour in a Wx StaticText or Button

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; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1170646]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 23:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found