project init
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
deno.lock
|
||||
gtk-test
|
||||
8
deno.json
Normal file
8
deno.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"tasks": {
|
||||
"dev": "deno run --watch --allow-all main.ts"
|
||||
},
|
||||
"imports": {
|
||||
"@sigmasd/gtk": "jsr:@sigmasd/gtk@^0.60.0"
|
||||
}
|
||||
}
|
||||
37
main.ts
Normal file
37
main.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import {
|
||||
Application,
|
||||
ApplicationFlags,
|
||||
ApplicationWindow,
|
||||
Box,
|
||||
Button,
|
||||
Label,
|
||||
Orientation,
|
||||
} from "@sigmasd/gtk/gtk4";
|
||||
|
||||
const app = new Application("com.example.HelloWorld", ApplicationFlags.NONE);
|
||||
|
||||
app.onActivate(() => {
|
||||
const win = new ApplicationWindow(app);
|
||||
win.setTitle("Hello World");
|
||||
win.setDefaultSize(400, 300);
|
||||
|
||||
const box = new Box(Orientation.VERTICAL, 12);
|
||||
box.setMarginTop(24);
|
||||
box.setMarginBottom(24);
|
||||
box.setMarginStart(24);
|
||||
box.setMarginEnd(24);
|
||||
|
||||
const label = new Label("Hello, GTK! 👋");
|
||||
box.append(label);
|
||||
|
||||
const button = new Button("Click Me!");
|
||||
button.onClick(() => {
|
||||
label.setText("Button clicked! 🎉");
|
||||
});
|
||||
box.append(button);
|
||||
|
||||
win.setChild(box);
|
||||
win.present();
|
||||
});
|
||||
|
||||
app.run([]);
|
||||
Reference in New Issue
Block a user