in reply to wxPerl button background

What module(s) are you using? I can guess what SetForegroundColour is supposed to do, but without any context, I have no idea if you have a simple spelling error, or are missing some environmental setting, or ...

1 Peter 4:10

Replies are listed 'Best First'.
Re^2: wxPerl button background
by xircon (Initiate) on Dec 17, 2014 at 20:01 UTC
    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

      I'm unable to test this directly (at work atm). I did note one thing in my quick search of the documentation: the paragraph on SetBackgroundColour warns that the method itself does not produce a visible change, the screen must be refreshed first.

      1 Peter 4:10
        That is it!
        $panel->Layout();
        Fixes the problem. My quest for knowledge continues.............. Cheers.

      I'd expect that if it does set the background red, the 3d Button effect ends up covering that red color.

      Perhaps try a BitmapButton instead?