diff --git a/examples/01_hello_world.pm6 b/examples/01_hello_world.pm6 index 3117532..8e9493a 100644 --- a/examples/01_hello_world.pm6 +++ b/examples/01_hello_world.pm6 @@ -1,20 +1,68 @@ use GTK::Simple; +=comment + Using C allows you to get a U for your app + by creating a B. + my GTK::Simple::App $app .= new(title => "Hello GTK!"); + +=begin comment + Anything that does the C role, like + C for example, lets you use B + to put widgets into its body. + + In other GTK tutorials, you'll find that you have to C + all widgets as well as the window. set_content does all of that for us. +=end comment + $app.set_content( GTK::Simple::VBox.new( - (my $button = GTK::Simple::Button.new(label => "Hello World!")), - (my $second = GTK::Simple::Button.new(label => "Goodbye!")) + my $button = GTK::Simple::Button.new(label => "Hello World!"), + my $second = GTK::Simple::Button.new(label => "Goodbye!") ) ); +=comment + Note the use of U of local variables for the Buttons. + This lets us refer to the buttons again later on, but not have to refer to + them twice in a row. + + +=comment + Setting the C of any C adds + a B. + C on a window, however, is special-cased to put + a border U the window instead. + $app.border_width = 20; -$second.sensitive = 0; -$button.clicked.tap({ .sensitive = 0; $second.sensitive = 1 }); +=comment + Using the sensitive property we can make a button unclickable. + +$second.sensitive = False; + + +=begin comment + The B member exposes activation events as a C that we + can tap. That C will C the Button object every time the + button is activated. + + Therefore we can set the button that was just clicked inactive with + just C<.sensitive = 0>. The C<$second> button can then be activated. +=end comment + +$button.clicked.tap({ .sensitive = False; $second.sensitive = True }); + + +=comment + Clicking the second button shall C the application's main loop. $second.clicked.tap({ $app.exit; }); + +=comment + Finally, we enter the main loop of the application. + $app.run;