1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#!/usr/bin/perl
use v5.20;
use warnings;
use Tickit;
use Tickit::Widgets qw( Border Button VBox RadioButton );
Tickit::Style->load_style( <<'EOF' );
Button {
fg: "black";
bg: "white";
}
EOF
my $border = Tickit::Widget::Border->new(
h_border => 10,
v_border => 2,
)
->set_child( my $vbox = Tickit::Widget::VBox->new( spacing => 2, style => { bg => "black" } ) );
my @buttons;
foreach my $colour (qw( red blue green yellow )) {
$vbox->add(
my $button = Tickit::Widget::Button->new(
label => $colour,
on_click => sub { $border->set_style( bg => $colour ) },
)
);
push @buttons, $button;
}
my $tickit = Tickit->new( root => $border );
$vbox->add(
my $button = Tickit::Widget::Button->new(
label => "Quit",
on_click => sub { $tickit->stop },
)
);
push @buttons, $button;
{
my $group = Tickit::Widget::RadioButton::Group->new;
$group->set_on_changed( sub {
my ( undef, $type ) = @_;
$_->set_style( linetype => $type ) for @buttons;
});
$vbox->add( Tickit::Widget::RadioButton->new(
label => $_,
value => $_,
group => $group,
) ) for qw( none single double thick );
}
$tickit->run;
|