Inherit Gtk Basic Window
主要範例
#!/usr/bin/gjs
const Lang = imports.lang;
const Gtk = imports.gi.Gtk;
const Win = new Lang.Class({
Name: 'Win',
Extends: Gtk.Window,
_init: function(args) {
this.parent({
title: 'Example: Inherit Gtk.Window',
default_width: 800,
default_height: 600,
type: Gtk.WindowType.TOPLEVEL
});
this.connect('delete-event', Gtk.main_quit);
},
run: function() {
this.show_all();
}
});
Gtk.init(null, null);
var win = new Win();
win.run();
Gtk.main();
API
- Gtk-3.0 / Gtk.Window / Gtk.Window.new
- Gtk-3.0 / Gtk.WindowType
WindowType
- Gtk.WindowType.TOPLEVEL
- Gtk.WindowType.POPUP
更多參考
- Arch Wiki / GTK+/Development / 1 Write a simple message dialog app / 1.16 JavaScript
- Github / Gnome / gjs / examples / gtk.js
- GNOME Developer Platform Demos / Tutorials, code samples and platform demos in JavaScript / Tutorial for beginners and code samples / Window
- GNOME application development overview / stable / Get started
- Github / Gnome / gjs / modules / lang.js
- classes, interfaces and properties in Javascript/gjs
- Wiki / Inheritance (object-oriented programming)