Commit | Line | Data |
---|---|---|
21c4e167 H |
1 | #!/usr/bin/env perl |
2 | # Sample Gtk2-Perl Glade app | |
3 | # check http://code.google.com/p/camelbox/ for running on windows | |
4 | ||
5 | use strict; | |
6 | use warnings; | |
7 | use utf8; | |
8 | use Gtk2 qw{ -init }; | |
9 | ||
10 | my $builder = Gtk2::Builder->new(); | |
11 | $builder->add_from_file( "sample.builder" ); | |
12 | ||
13 | my %widgets; | |
14 | foreach my $widget qw(window1 label1 entry1) | |
15 | { | |
16 | $widgets{$widget}=$builder->get_object($widget); | |
17 | } | |
18 | ||
19 | $builder->connect_signals( undef ); | |
20 | $builder = undef; | |
21 | ||
22 | $widgets{'window1'}->show(); | |
23 | ||
24 | Gtk2->main(); | |
25 | exit; | |
26 | ||
27 | ||
28 | sub on_button1_clicked | |
29 | { | |
30 | $widgets{'label1'}->set_text($widgets{'entry1'}->get_text()); | |
31 | print 'Label1 text set to: '.$widgets{'label1'}->get_text()."\n"; | |
32 | } | |
33 | ||
34 | ||
35 | sub cb_destroy | |
36 | { | |
37 | Gtk2->main_quit(); | |
38 | } |