van-gtk
v0.0.9
Published
A library lets you create GUI with [vanjs](https://vanjs.org) and [gjs](https://gjs.guide/guides/gtk/3/03-installing.html#installing-gjs) in a reactive way.
Downloads
564
Readme
van-gtk = vanjs + gtk4
A library lets you create GUI with vanjs and gjs in a reactive way.
Hello World
You should have installed gjs. Example for Archlinux
sudo pacman -S gjs
Create a npm project
npm init
Install dependencies
npm install van-gtk npm install -D esbuild
Create index.js
import Gtk from 'gi://Gtk?version=4.0'; import { app, Button, Box, Label, van } from 'van-gtk' app(()=>{ const count = van.state(0) const win = new Gtk.Window({ child: Box( Button({ label: "Inc", onclicked: () => { count.val++; } }), count, Button({ label: "Dec", onclicked: () => { count.val--; } }), )}); return win; }) .exitOnClose() .run()
Create esbuild.mjs
import { build } from "esbuild"; await build({ entryPoints: ['index.js'], outdir: 'dist', bundle: true, target: "firefox115", // Since GJS 1.77.2 format: 'esm', external: ['gi://*', 'resource://*', 'gettext', 'system', 'cairo'], })
Build
node esbuild.mjs
Run
gjs -m dist/main.js