Skip to content

Instantly share code, notes, and snippets.

@yurenju
Created May 23, 2011 05:05
Show Gist options
  • Save yurenju/986247 to your computer and use it in GitHub Desktop.
Save yurenju/986247 to your computer and use it in GitHub Desktop.
javascript gtk example
const Gtk = imports.gi.Gtk;
function hello(widget) {
log("Hello World");
}
function onDestroy(widget) {
log("destroy signal occurred");
Gtk.main_quit();
}
Gtk.init(0, null);
let win = new Gtk.Window({ type: Gtk.WindowType.TOPLEVEL });
win.connect("destroy", onDestroy);
let button = new Gtk.Button({ label: "Hello World" });
button.connect("clicked", hello);
button.connect("clicked", function() {
win.destroy();
});
win.add(button);
button.show();
win.show();
Gtk.main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment