Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: wxPerl Static Text alignment

by Anonymous Monk
on Nov 08, 2013 at 11:57 UTC ( #1061708=note: print w/ replies, xml ) Need Help??


in reply to Re^2: wxPerl Static Text alignment
in thread wxPerl Static Text alignment

Example

#!/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::wxNullCo +lour(); } } } ## end BEGIN __END__

Instead of WxPanel try naming your panel label_panel or left_label_panel ... naming your widgets/controls descriptively is important

One way of keeping track (what goes where) is naming your sizer/container elements by position, and incorporating the parent/child relationship into the name. Afterwards you incorporate your action elements (text/buttons) and name then by purpose/property/action (email_input/email_text,submit_button,cancel_button... )

I like Wx :) Re: wxPerl: is BitmapFromImage implemented? (no;sleep;docs), my wxWidgets / wxPerl / wxGlade tutorial, http://www.wxperl.it/p/wxperl-primer.html , wxperl_usage / wxperl-usage / wxPerl::Usage / Class Method Browser , available methods, method invocation syntax, link to docs, Re^8: How to use wxHtmlEasyPrinting (On debugging, verify everything, talk to teddybear ... and links and links , Tutorials: Perl documentation documentation, Searching Perl Documentation

you don't need to build wx yourself, http://www.citrusperl.com/, http://ppm.wxperl.it/

What Do These Sizer Things Do?


Comment on Re^3: wxPerl Static Text alignment
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2015-07-29 05:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls