welsonjs/gtkdemo.js

69 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-10-27 05:44:09 +00:00
var GTK = require("lib/gtk");
function main() {
GTK.init(function() {
2020-10-28 08:18:17 +00:00
var win, table, button, entry, text, radiogroup, radio1, radio2;
// create new window
win = new GTK.Window({
2020-10-28 08:43:24 +00:00
title: "WelsonJS GTK GUI Demo Application",
2020-10-28 08:18:17 +00:00
width: 450,
height: 400
});
// create new table
table = new GTK.Table({
rows: 50,
columns: 50
});
win.setContainer(table);
// create new button
button = new GTK.Button({
text: "Exit"
});
2020-10-28 08:31:30 +00:00
button.addEventListener("click", function() {
2020-10-28 08:18:17 +00:00
GTK.exit();
});
table.attach(button, 41, 49, 45, 49);
// create new entry
entry = new GTK.Entry();
table.attach(entry, 1, 40, 45, 49);
2020-10-28 08:43:24 +00:00
entry.addEventListener("enter", function(event) {
console.info(event.target.getText());
});
2020-10-28 08:18:17 +00:00
// create new textbox
text = new GTK.TextBox();
2020-10-28 08:31:30 +00:00
table.attach(text, 1, 49, 8, 44);
2020-10-28 08:18:17 +00:00
// create new radiogroup
radiogroup = new GTK.RadioGroup();
// create new radio (Radio 1)
radio1 = new GTK.RadioBox({
text: "Yes",
group: radiogroup
});
table.attach(radio1, 1, 10, 1, 4);
// create new radio (Radio 2)
radio2 = new GTK.RadioBox({
text: "No",
group: radiogroup
});
table.attach(radio2, 1, 10, 4, 7);
// showing window
2020-10-27 05:44:09 +00:00
win.show();
2020-10-28 08:43:24 +00:00
2020-10-28 08:18:17 +00:00
// focusing entry
entry.focus();
2020-10-27 05:44:09 +00:00
});
2020-10-28 08:18:17 +00:00
GTK.wait();
2020-10-27 05:44:09 +00:00
}
exports.main = main;