Leser: 3
![]() |
|< 1 2 >| | ![]() |
17 Einträge, 2 Seiten |
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
#!/usr/bin/perl use strict; use warnings; use Gtk2 -init; use Gtk2::GladeXML; my $gfile='test.glade'; my $count=0; my $glade=Gtk2::GladeXML->new($gfile,'mainwin'); $glade->signal_autoconnect_from_package('main'); $glade->get_widget('mainwin')->show_all(); Gtk2->main; sub do_add_template { my $pos=$count; my $template=Gtk2::GladeXML->new($gfile,'hbox_template'); my $label=$template->get_widget('label_info'); $label->set_label(''); $template->get_widget('button_template')->signal_connect(clicked => sub{ $label->set_label(sprintf("Position: %02u",$pos)); }); my $widget=$template->get_widget('hbox_template'); $glade->get_widget('vbox_insert')->pack_start($widget, 0, 1, 0); $count++; } sub do_ende { Gtk2->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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Sat Dec 13 19:57:21 2008 -->
<glade-interface>
<widget class="GtkWindow" id="mainwin">
<signal name="destroy" handler="do_ende"/>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="spacing">5</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<child>
<widget class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="resize_mode">GTK_RESIZE_QUEUE</property>
<child>
<widget class="GtkVBox" id="vbox_insert">
<property name="visible">True</property>
<property name="spacing">5</property>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkButton" id="button2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="do_add_template"/>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="spacing">5</property>
<child>
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="stock">gtk-about</property>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">Template Hinzufügen</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="stock">gtk-about</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">gtk-quit</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="do_ende"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkWindow" id="template">
<child>
<widget class="GtkHBox" id="hbox_template">
<property name="visible">True</property>
<property name="spacing">5</property>
<child>
<widget class="GtkLabel" id="label_info">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">xxx</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button_template">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">gtk-about</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="do_info"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-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
#!/usr/bin/perl use strict; use warnings; use Gtk2 -init; use Gtk2::GladeXML::Simple; my $gfile='test.glade'; my $gmain=mainwin->new($gfile); $gmain->run(); { package mainwin; use base 'Gtk2::GladeXML::Simple'; sub new { my $class=shift; my $gfile=shift; my $self=bless($class->SUPER::new($gfile,'mainwin'), $class); $self->{GLADEFILE}=$gfile; $self->{COUNT}=0; $self->{mainwin}->show_all(); return $self; } sub do_ende { Gtk2->main_quit; } sub do_add_template { my $self=shift; $self->{COUNT}++; my $template=template->new($self->{GLADEFILE},$self->{COUNT}); my $widget=$template->get_template_widget(); $self->{vbox_insert}->pack_start($widget, 0, 1, 0); } } { package template; use base 'Gtk2::GladeXML::Simple'; sub new { my $class=shift; my $gfile=shift; my $pos=shift; my $self=bless($class->SUPER::new($gfile,'hbox_template'), $class); $self->{POSITION}=$pos; $self->{label_info}->set_label(''); return $self; } sub do_info { my $self=shift; $self->{label_info}->set_label(sprintf("Position: %02u",$self->{POSITION})); } sub get_template_widget { return shift()->{hbox_template}; } }
1 2 3 4 5 6
sub do_remove_all_templates { my $box=$glade->get_widget('vbox_insert'); for my $widget ($box->get_children()) { $box->remove($widget); } }
pp -o packed.exe source.pl
$path=$ENV{PAR_TEMP}."/inc/$path" if($ENV{PAR_TEMP});
pp -p -I own/modules/ -a application.glade -a application.conf application.pl
pp -o application a.par
![]() |
|< 1 2 >| | ![]() |
17 Einträge, 2 Seiten |