Skip to content

Commit e563aed

Browse files
committed
Added separators and switches
1 parent dbda699 commit e563aed

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

8c-Switch.pl

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#! /usr/bin/perl
2+
3+
use strict;
4+
use warnings;
5+
use diagnostics;
6+
use feature ':5.14';
7+
use Gtk3 '-init';
8+
use Glib qw/TRUE FALSE/;
9+
use Data::Dumper;
10+
11+
my $window = Gtk3::Window->new('toplevel');
12+
$window->set_title("Switch Example");
13+
$window->set_position("mouse");
14+
$window->set_default_size(250, 100);
15+
$window->set_border_width(5);
16+
$window->signal_connect (delete_event => sub { Gtk3->main_quit });
17+
18+
my $vbox = Gtk3::Box->new("vertical", 5);
19+
$window->add($vbox);
20+
21+
my $spinner = Gtk3::Spinner->new;
22+
my $switch = Gtk3::Switch->new;
23+
$switch->set_active( FALSE );
24+
25+
$vbox->pack_start($spinner, TRUE, TRUE, 5 );
26+
$vbox->pack_start($switch, TRUE, TRUE, 5 );
27+
28+
$switch->signal_connect( 'notify::active' => \&toggle );
29+
30+
$window->show_all;
31+
Gtk3->main;
32+
33+
sub toggle {
34+
my ($widget, $data) = @_;
35+
say Dumper($data);
36+
if ( $widget->get_active == TRUE ) {
37+
$spinner->start;
38+
} else {
39+
$spinner->stop;
40+
}
41+
return FALSE;
42+
}

8d-Separators.pl

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#! /usr/bin/perl
2+
3+
use strict;
4+
use warnings;
5+
use diagnostics;
6+
use feature ':5.14';
7+
use Gtk3 '-init';
8+
use Glib qw/TRUE FALSE/;
9+
use Data::Dumper;
10+
11+
my $window = Gtk3::Window->new('toplevel');
12+
$window->set_title("Switch Example");
13+
$window->set_position("mouse");
14+
$window->set_default_size(250, 100);
15+
$window->set_border_width(5);
16+
$window->signal_connect (delete_event => sub { Gtk3->main_quit });
17+
18+
my $vbox = Gtk3::Box->new("vertical", 5);
19+
$window->add($vbox);
20+
21+
my $spinner = Gtk3::Spinner->new;
22+
my $switch = Gtk3::Switch->new;
23+
$switch->set_active( FALSE );
24+
25+
my $sep = Gtk3::Separator->new("horizontal");
26+
27+
$vbox->pack_start($spinner, TRUE, TRUE, 5 );
28+
$vbox->pack_start($sep, FALSE, FALSE, 2 );
29+
$vbox->pack_start($switch, TRUE, TRUE, 5 );
30+
31+
$switch->signal_connect( 'notify::active' => \&toggle );
32+
33+
$window->show_all;
34+
Gtk3->main;
35+
36+
sub toggle {
37+
my ($widget, $data) = @_;
38+
say Dumper($data);
39+
if ( $widget->get_active == TRUE ) {
40+
$spinner->start;
41+
} else {
42+
$spinner->stop;
43+
}
44+
return FALSE;
45+
}

Perl Gtk3 Tutorial.odt

13.9 KB
Binary file not shown.

Perl Gtk3 Tutorial.pdf

16.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)