PracticeDev/study_perl/test_gtk.pl

53 lines
1.0 KiB
Perl
Raw Normal View History

2022-12-20 17:31:11 +08:00
#!/usr/bin/perl
BEGIN { $ENV{LC_ALL} = "he_IL"; }
use utf8; # Needed for Hebrew
use Gtk2 '-init';
Gtk2::Rc->parse_string(<<__);
include "/usr/local/share/themes/Bumblebee/gtk-2.0/gtkrc"
style "normal" {
font_name ="serif 30"
}
style "my_entry" {
font_name ="sans 25"
text[NORMAL] = "#FF0000"
}
widget "*" style "normal"
widget "*Entry*" style "my_entry"
__
my $window = Gtk2::Window->new;
$window->set_title ("Hello world");
$window->signal_connect (destroy => sub { Gtk2->main_quit; });
my $vbox = Gtk2::VBox->new();
$vbox->set("border_width"=> 10);
$window->add($vbox);
my $label = Gtk2::Label->new("שלום עולם! 中文测试");
$vbox->pack_start($label,0,0,5); # expand?, fill?, padding
my $entry = Gtk2::Entry->new();
$vbox->pack_start($entry,0,0,5);
my $button = Gtk2::Widget->new("Gtk2::Button",
label=>"יציאה");
$button->signal_connect(clicked=>\&my_quit);
$vbox->pack_start($button, 0,0,5);
$window->show_all();
Gtk2->main;
sub my_quit {
print "Lehitraot!\n";
exit;
}