Very new to perl. Manjaro linux, wx installed via cpanm. Very simple script
#!/usr/bin/perl -w use strict; use Wx; my $backcolor = Wx::Colour->new('#123582'); my $butbackcol = Wx::Colour->new('#198cff'); ## Button margin my $l=5; ## Centre screen workaround #my $cw=1366/2; #my $ch=500/2; package MyFrame; use base 'Wx::Frame'; # import the event registration function use Wx::Event qw(EVT_BUTTON); sub new { my $ref = shift; my $self = $ref->SUPER::new( undef, # parent window -1, # ID -1 means any 'Variety Control', # title [50, 50], # default position [100, 150], # size ); my $panel = Wx::Panel->new( $self, # parent window -1, # ID ); $panel->SetBackgroundColour($backcolor); my $button1 = Wx::Button->new( $panel, # parent window -1, # ID 'Next >>', # label [$l, 10], # position [-1, -1], # default size ); # register the OnClick method as an handler for the # 'button clicked' event. The first argument is a Wx::EvtHandler # that receives the event # $button1->SetBackgroundColour($butbackcol); EVT_BUTTON( $self, $button1, \&OnClick1 ); my $button2 = Wx::Button->new( $panel, # parent window -1, # ID '<<Previous', # label [$l, 50], # position [-1, -1], # default size ); ## Here is where I am having problems : $button2->SetForegroundColour(Wx::Colour->new(177,77,77)); + $button2->SetBackgroundColour(Wx::Colour->new(177,77,77)); #$button2->SetBackgroundColour(Wx::Colour->new('red')); # register the OnClick method as an handler for the # 'button clicked' event. The first argument is a Wx::EvtHandler # that receives the event EVT_BUTTON( $self, $button2, \&OnClick2 ); my $button3 = Wx::Button->new( $panel, # parent window -1, # ID 'Trash', # label [$l, 90], # position [-1, -1], # default size ); # register the OnClick method as an handler for the # 'button clicked' event. The first argument is a Wx::EvtHandler # that receives the event EVT_BUTTON( $self, $button3, \&OnClick3 ); return $self; } # this method receives as its first parameter the first argument # passed to the EVT_BUTTON function. The second parameter # always is a Wx::Event subclass sub OnClick1 { my( $self, $event ) = @_; #$self->SetTitle( 'Clicked' ); system("variety","-n"); } sub OnClick2 { my( $self, $event ) = @_; #$self->SetTitle( 'Clicked' ); system("variety","-p"); } sub OnClick3 { my( $self, $event ) = @_; #$self->SetTitle( 'Clicked' ); system("variety","-t"); } package MyApp; use base 'Wx::App'; sub OnInit { my $frame = MyFrame->new; $frame->Centre("wxBoth"); $frame->Show( 1 ); } package main; my $app = MyApp->new; $app->MainLoop;
To control variety wallpaper changer, playing with a simple example to expand my knowledge. wxperl
yaourt wx | grep -i installed 2 extra/wxgtk 3.0.2-2 [installed] 3 extra/wxgtk2.8 2.8.12.1-2 [installed] 11 community/wxsqlite3 3.1.1-1 [installed] 43 aur/perl-alien-wxwidgets 0.65-1 [installed] (43) 45 aur/perl-wx 0.9923-1 [installed] (35) 47 aur/perl-wx-perl-processstream 0.32-1 [installed] (8) 48 aur/perl-wx-scintilla 0.40_02-2 [installed] (5) 86 aur/wxformbuilder-bin 3.1.70-2 [installed] (3)
Is the best I can do. Steve

In reply to Re^2: wxPerl button background by xircon
in thread wxPerl button background by xircon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.