Last active
July 25, 2023 04:24
-
-
Save itsuki-hayashi/f0c532c353abb8d5125232667b988a18 to your computer and use it in GitHub Desktop.
GTK4 Hello world in Perl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
use v5.38; | |
use Glib::Object::Introspection; | |
Glib::Object::Introspection->setup( | |
basename => 'Gio', | |
version => '2.0', | |
package => 'Gio'); | |
Glib::Object::Introspection->setup( | |
basename => 'Gtk', | |
version => '4.0', | |
package => 'Gtk'); | |
Glib::Object::Introspection->setup( | |
basename => 'Gdk', | |
version => '4.0', | |
package => 'Gdk'); | |
Glib::Object::Introspection->setup( | |
basename => 'Gsk', | |
version => '4.0', | |
package => 'Gsk'); | |
my $app = Gtk::Application->new('org.gtk.HelloApp', 'flags-none'); | |
# When the application is launched | |
$app->signal_connect(activate => sub { | |
# create a new window | |
my $win = Gtk::ApplicationWindow->new($app); | |
# with a button in it | |
my $btn = Gtk::Button->new_with_label('Hello World!'); | |
# which closes the window when clicked | |
$btn->signal_connect(clicked => sub { $win->close(); }); | |
$win->set_child($btn); | |
$win->present(); | |
}); | |
# Run the application | |
$app->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment