-
Notifications
You must be signed in to change notification settings - Fork 15
/
gtk1.pl
30 lines (23 loc) · 854 Bytes
/
gtk1.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Translated from http://www.mono-project.com/GtkSharp:_Hello_World
constant $GTK = "gtk-sharp,Version=2.12.0.0,Culture=neutral,PublicKeyToken=35e10195dab3c99f";
constant Application = CLR::("Gtk.Application,$GTK");
constant Window = CLR::("Gtk.Window,$GTK");
constant Button = CLR::("Gtk.Button,$GTK");
Application.Init;
# Set up a button object.
my $btn = Button.new("Hello World");
$btn.add_Clicked: sub ($obj, $args) { #OK
# runs when the button is clicked.
say "Hello World";
Application.Quit;
};
my $window = Window.new("helloworld");
$window.add_DeleteEvent: sub ($obj, $args) { #OK
# runs when the user deletes the window using the "close
# window" widget in the window frame.
Application.Quit;
};
# Add the button to the window and display everything
$window.Add($btn);
$window.ShowAll;
Application.Run;