#!/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 '<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; #### 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)