#!/usr/bin/perl -- ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr -ce -nibc -i=4 -pt=0 "-nsak=*" use strict; use warnings; use Wx (); Main( @ARGV ); exit( 0 ); sub Main { GoWx(); GoWx( qw/ fa fa fa / ); } sub GoWx { my @sides = ( Wx::wxALIGN_LEFT(), Wx::wxALIGN_RIGHT(), Wx::wxALIGN_CENTRE(), ); my @stats = qw/ I cant sleep cause my bed's on fire Don't touch me I'm a real live wire /; my $app = Wx::SimpleApp->new; my $frame = Wx::Frame->new( undef, -1, @_ ? "@_" : $0 ); my $panel = Wx::Panel->new( $frame, -1, [ -1, -1 ], [ 160, -1 ] ); $frame->SetBackgroundColour( Wx::ColourDatabase::Find( 'red' ) ); $panel->SetBackgroundColour( Wx::ColourDatabase::Find( 'green' ) ); $frame->SetSizer( Wx::BoxSizer->new( Wx::wxHORIZONTAL() ) ); $frame->GetSizer->Add( $panel, 0, Wx::wxEXPAND(), Wx::wxALL(), 20 ); $panel->SetSizer( Wx::BoxSizer->new( Wx::wxVERTICAL() ) ); for my $word ( @stats ) { my $side = rand @sides ; my( $width, $height ); { my $autos = Wx::StaticText->new( $panel, -1, "$word:" ); ( $width, $height ) = $autos->GetSizeWH; $autos->Destroy; } my $static = Wx::StaticText->new( $panel, -1, "$word:", [-1,-1], [ $width + 10 + rand 100 ,-1], #~ $sides[ rand @sides ], $sides[ @sides - 1 - $side ], ); $static->SetBackgroundColour( colors() ); $panel->GetSizer->Add( $static, 0, $sides[ $side ], Wx::wxALL(), 20 ); } if( @_ ) { my $pink = Wx::Panel->new( $frame, -1, [ -1, -1, ], [ 120, -1 ], ); $pink->SetBackgroundColour( Wx::ColourDatabase::Find( 'pink' ) ); $frame->GetSizer->Add( $pink, 0, Wx::wxEXPAND(), Wx::wxALL(), 20 ); } $app->SetTopWindow( $frame ); $frame->Maximize( 1 ); $frame->Show; $app->MainLoop; } ## end sub GoWx BEGIN { my $counter = 0; my @colors = qw[ yellow orchid orange plum GOLDENROD CORAL gold ]; sub colors { $counter = 0 if $counter >= @colors; my $color; while( 1 ) { $color = Wx::ColourDatabase::Find( $colors[ $counter++ ] ); return $color if defined $color and $color != Wx::wxNullColour(); } } } ## end BEGIN __END__