Deno port of Gnome libraries (such as Gtk).
Early Stage and Unstable
You must specify --allow-ffi
and --unstable-ffi
flags to run your program.
deno run --allow-ffi --unstable-ffi <file>
Import libraries from gir.deno.dev
to load them.
Loading Gtk:
import Gtk from "https://gir.deno.dev/Gtk-4.0";
Objects are initialized using creation functions or javascript constructors.
Creating a GtkButton:
const button = Gtk.Button.new_with_label("Click Me!");
or
const button = new Gtk.Button({ label: "Click Me!" });
Signals are connected using on
method.
Connecting clicked
signal to a button:
button.connect("clicked", () => {
console.log("Clicked");
});
import Gtk from "https://gir.deno.dev/Gtk-4.0";
const app = new Gtk.Application();
app.connect("activate", () => {
const win = new Gtk.ApplicationWindow({ application: app });
const contentArea = new Gtk.Box();
const label = new Gtk.Label({ label: "Hello World!" });
contentArea.append(label);
win.set_child(contentArea);
win.present();
});
app.run([]);
See more examples on examples folder.
Deno GI depends on gobject-introspection
.
dnf install gobject-introspection
apt install gobject-introspection
pacman -S gobject-introspection
brew install gobject-introspection
- Install MSYS2.
- Add
C:\msys64\mingw64\bin
to system path. - Run in msys shell:
pacman -S mingw-w64-x86_64-gobject-introspection
Additional libraries such as gtk4
and libadwaita
are used in examples.
Their installation process is the same as gobject-introspection
.