codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
use Glib qw/TRUE FALSE/; use Gtk2 '-init'; sub callback { my ($button, $data) = @_; print "Hello again - $data was pressed\n"; } sub delete_event { Gtk2->main_quit; return FALSE; } sub Button{ my $title = shift; my $box = shift; $button = Gtk2::Button->new($title); $button->signal_connect(clicked => \&callback, $title); $box->pack_start($button, TRUE, TRUE, 0); $button->show; $box->show; } $window = Gtk2::Window->new('toplevel'); $window->set_title("Hello Buttons!"); $window->signal_connect(delete_event => \&delete_event); $window->set_border_width(20); $box = Gtk2::VBox->new(FALSE, 0); $window->add($box); $box1 = Gtk2::VBox->new(FALSE, 0); $box->add($box1); $box2 = Gtk2::HBox->new(FALSE, 0); $box->add($box2); $box3 = Gtk2::HBox->new(FALSE, 0); $box->add($box3); foreach my $index(1..3){ Button('Box1-'.$index,$box1); } foreach my $index(1..2){ Button('Box2-'.$index,$box2); } foreach my $index(1..5){ Button('Box3-'.$index,$box3); } $box->show; $window->show; Gtk2->main; 0;
Private
[
?
]
Run code
Submit