Skip to content

Commit

Permalink
an example using toggle- and check-button.
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed May 24, 2014
1 parent ccc0f1b commit 3993435
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/02_toggles.pm6
@@ -0,0 +1,25 @@
use GTK::Simple;

my GTK::Simple::App $app .= new(title => "Toggle buttons");

$app.set_content(
GTK::Simple::VBox.new(
my $check_button = GTK::Simple::CheckButton.new(label => "check me out!"),
my $status_label = GTK::Simple::Label.new(text => "the toggles are off and off"),
my $toggle_button = GTK::Simple::ToggleButton.new(label=> "time to toggle!"),
)
);

$app.border_width = 50;

enum ToggleState <off on>;

sub update_label($b) {
$status_label.text = "the toggles are " ~
($check_button, $toggle_button)>>.status.map({ ToggleState $_ }).join(" and ");
}

$check_button\.toggled.tap: &update_label;
$toggle_button.toggled.tap: &update_label;

$app.run;

0 comments on commit 3993435

Please sign in to comment.