41 lines
1005 B
Plaintext
Raw Normal View History

2025-08-20 22:17:34 +02:00
// main.wren
import "gtk" for Gtk, Window, Box, Button, Entry, Label
// Optional: your host can still expose this to quit if needed, but not required here
// foreign class Host { foreign static signalDone() }
var ui = Fiber.new {
Gtk.init()
var win = Window.new("Wren + GTK", 420, 200)
var root = Box.vbox(8)
var info = Label.new("Type something and click the button:")
var entry = Entry.new()
var btn = Button.new("Say hi")
root.packStart(info, false, false, 0)
root.packStart(entry, false, false, 0)
root.packStart(btn, false, false, 0)
win.add(root)
// Quit the app when the window is closed
win.onDestroy { Gtk.quit() }
// Update the label with the current entry text
btn.onClicked {
info.setText("You typed: " + entry.text)
}
// Also submit on Enter key in the entry
entry.onActivate {
info.setText("Enter pressed: " + entry.text)
}
win.showAll()
Gtk.run()
// Host.signalDone() // if you want to tell your C host to exit
}
ui.call()