Commit | Line | Data |
---|---|---|
21c4e167 H |
1 | #!/usr/bin/env perl |
2 | #GTK Hello world! by Harvie 2oo9 | |
3 | ||
4 | use strict; | |
5 | use warnings; | |
6 | use utf8; | |
7 | use Gtk2 qw(-init); | |
8 | ||
9 | my $builder = Gtk2::Builder->new(); | |
10 | $builder->add_from_file('hello.ui'); | |
11 | ||
12 | my %widgets; | |
13 | foreach my $widget qw(window1 button1 entry1) | |
14 | { | |
15 | $widgets{$widget}=$builder->get_object($widget); | |
16 | } | |
17 | ||
18 | $builder->connect_signals( undef ); | |
19 | $builder = undef; | |
20 | ||
21 | $widgets{'window1'}->show(); | |
22 | ||
23 | Gtk2->main(); | |
24 | exit; | |
25 | ||
26 | sub on_window1_destroy | |
27 | { | |
28 | Gtk2->main_quit(); | |
29 | } | |
30 | ||
31 | sub on_button1_clicked | |
32 | { | |
33 | $widgets{'button1'}->set_label($widgets{'entry1'}->get_text()); | |
34 | print $widgets{'entry1'}->get_text()."\n"; | |
35 | } | |
36 | ||
37 | ||
38 |