Source

WxPerlBook / example / 01_ratio_selector.pl

use v5.12;
use warnings;

package App;
use parent qw(Wx::App);
use Wx;

my %ratio = (Golden => 1.618, Din => 1.41421, '2:3' => 1.5,  Square => 1);

sub OnInit {
	my $app   = shift;
	my $frame = Wx::Frame->new( undef, -1, 'Golden Proportion');

	my $button = Wx::Choice->new($frame, -1, [-1,-1], [-1,-1], [keys %ratio]);
	Wx::Event::EVT_CHOICE( $button, $button, sub {
		my $size = $frame->GetSize;
		$size->SetWidth( $size->GetHeight * $ratio{ $_[1]->GetString } ) ;
		$frame->SetSize( $size );
	} );

	$frame->Center();
	$frame->Show(1);
	$app->SetTopWindow($frame);
	1;
}

package main;
App->new->MainLoop;