forked from finanalyst/GTK-Simple
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05-bars.pl6
executable file
·80 lines (59 loc) · 2.11 KB
/
05-bars.pl6
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env perl6
use v6;
use lib 'lib';
use GTK::Simple;
use GTK::Simple::App;
my GTK::Simple::App $app = GTK::Simple::App.new(title => 'Boxes');
my GTK::Simple::StatusBar $status = GTK::Simple::StatusBar.new;
$status.tooltip-text = "I am a status bar";
my $root_ctx = $status.get-context-id("Root");
$status.push-status($root_ctx, "Running");
my $button1 = GTK::Simple::Button.new(label => "button one");
my $button1_ctx = $status.get-context-id("Button One");
$button1.tooltip-text = "I'm a button";
my $button2 = GTK::Simple::Button.new(label => "button two");
my $button2_ctx = $status.get-context-id("Button One");
$button2.tooltip-text = "I'm another button";
my $progress = GTK::Simple::ProgressBar.new;
$progress.tooltip-text = "And this is a progress bar";
$button1.clicked.tap({
if $progress.fraction < 1.0 {
$progress.fraction += 0.2;
$status.push-status($button1_ctx, "Button One Clicked - { $progress.fraction * 100 }%");
if $progress.fraction == 1.0 {
$button1.label = "Done";
$button2.label = "Done";
}
}
else {
$app.exit;
}
});
$button2.clicked.tap({
if $progress.fraction < 1.0 {
$progress.fraction += 0.2;
$status.push-status($button2_ctx, "Button Two Clicked - { $progress.fraction * 100 }%");
if $progress.fraction == 1.0 {
$button1.label = "Done";
$button2.label = "Done";
}
}
else {
$app.exit;
}
});
my $hbox = GTK::Simple::HBox.new($button1, $button2);
my $frame = GTK::Simple::Frame.new(label => "Status");
$frame.set-content($status);
my $action = GTK::Simple::ActionBar.new;
$action.tooltip-text = "this is an action bar";
$action.pack-start(GTK::Simple::Button.new(label => 'Action Bar Left'));
$action.pack-end(GTK::Simple::Button.new(label => 'Action Bar Right'));
my $sep1 = GTK::Simple::Separator.new;
my $sep2 = GTK::Simple::Separator.new;
my $sep3 = GTK::Simple::Separator.new;
my $vbox = GTK::Simple::VBox.new($hbox,$sep1, $progress, $sep2, $action, $sep3, $frame);
$vbox.spacing = 10;
$app.set-content($vbox);
$app.border-width = 20;
$app.run;