[ create a new paste ] login | about

Link: http://codepad.org/MWIvpw5j    [ raw code | output | fork ]

Perl, pasted on Oct 31:
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;


Output:
1
2
Can't locate Glib.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i486-linux /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i486-linux /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl .) at line 1.
BEGIN failed--compilation aborted at line 1.


Create a new paste based on this one


Comments: