From df0b11c7dd20e978f2a9bcc7df7846f66c5dfcb8 Mon Sep 17 00:00:00 2001 From: Timo Paulssen Date: Sat, 24 May 2014 14:01:21 +0200 Subject: [PATCH] lots of comments for the second example --- examples/02_toggles.pm6 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/examples/02_toggles.pm6 b/examples/02_toggles.pm6 index 98e6b3e..bf13f66 100644 --- a/examples/02_toggles.pm6 +++ b/examples/02_toggles.pm6 @@ -1,7 +1,16 @@ use GTK::Simple; +=comment + Like every GTK::Simple application, we begin by + creating a new C. + my GTK::Simple::App $app .= new(title => "Toggle buttons"); +=comment + This time, we create a C to display a bit of + info to the user and above and below that we create one + C and a C. + $app.set_content( GTK::Simple::VBox.new( my $check_button = GTK::Simple::CheckButton.new(label => "check me out!"), @@ -10,16 +19,33 @@ $app.set_content( ) ); +=comment + Since the window would end up terribly tiny otherwise, we set a + quite generous inner border for the window + $app.border_width = 50; +=comment + This eases stringification of the toggle status a bit. + enum ToggleState ; +=comment + This sub will be called whenever we toggle either of the two Buttons. + sub update_label($b) { $status_label.text = "the toggles are " ~ ($check_button, $toggle_button)>>.status.map({ ToggleState $_ }).join(" and "); } +=comment + Now all we need to do is to connect the C sub to the + C supply of the buttons. + $check_button\.toggled.tap: &update_label; $toggle_button.toggled.tap: &update_label; +=comment + Finally, we let the event loop run. + $app.run;