1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
use strict; use warnings; use feature "say"; use Gtk3 qw( -init ); my $builder; my $window; $window = Gtk3::Window->new(); $builder= Gtk3::Builder->new(); $builder->add_from_file("test.glade"); $builder->connect_signals(undef); my $main_window = $builder->get_object("window1"); $main_window->show_all; Gtk3::main; package Handlers; sub exit{ Gtk3::main_quit; }
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
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkApplicationWindow" id="window">
<property name="can_focus">False</property>
<property name="startup_id">app.test</property>
<child>
<object class="GtkBox" id="box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage" id="image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">171</property>
<property name="icon_name">applications-system</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Hello World</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">1</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button">
<property name="label" translatable="yes">Quit</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="action_name">win.fullscreen</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
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
#! /usr/bin/perl
BEGIN {
use Glib::Object::Introspection;
Glib::Object::Introspection->setup(
basename => 'Gio',
version => '2.0',
package => 'Glib::IO');
}
package MyWindow;
use strict;
use warnings;
use utf8;
binmode STDOUT, ':utf8';
use Gtk3;
use Glib ('TRUE', 'FALSE');
use base 'Gtk3::ApplicationWindow';
sub new {
my $window;
# a buidler to add the UI designed with Glade to the grid:
my $builder = Gtk3::Builder->new();
# get the file (if it is there)
$builder->add_from_file('test.glade') or die 'file not found';
$window = $builder->get_object('window');
# fullscreen action
my $fullscreen_action = Glib::IO::SimpleAction->new('fullscreen',undef);
$fullscreen_action->signal_connect('activate'=>\&fb_cb);
$window->add_action($fullscreen_action);
return $window;
}
sub fb_cb {
print "YEAH\n";
}
package main;
use strict;
use warnings;
use utf8;
binmode STDOUT, ':utf8';
use Gtk3;
use Glib ('TRUE', 'FALSE');
my $app = Gtk3::Application->new('app.test', 'flags-none');
$app->signal_connect('activate' => \&_build_ui );
$app->run(\@ARGV);
exit;
sub _build_ui {
my ($app) = @_;
my $window = MyWindow->new();
$app->add_window($window);
$window->show_all();
}
Guest tsomWenn dir niemand antwortet, dann bestimmt nicht aus Ignoranz, sondern weil niemand was weiß.Kann mir denn keiner weiter helfen?