Introduction
KScript.UI lets a script open a native window on macOS, Windows or Linux. You describe the window's layout and its state in the script, and KScript draws it. There is nothing else to write: no Swift, C#, XAML or shell scripts.
To get started, import the package and write a Window { } block (<KScript.Window> in XML):
<KScript.Window title="Counter" width="320" height="200">
<let name="count" value="0" />
<Text size="32">{$count}</Text>
<Row>
<Button variant="primary" on_click="$count += 1">Add one</Button>
<Button on_click="$count = 0" disabled="$count == 0">Reset</Button>
</Row>
</KScript.Window>import KScript.UI
Window(title: 'Counter', width: 320, height: 200) {
$count = 0
Text(size: 32) "{$count}"
Row {
Button(variant: primary, on_click: $count += 1) "Add one"
Button(on_click: $count = 0, disabled: $count == 0) "Reset"
}
}kscript counter.kscript opens the window, and the script ends when the window is closed. A window needs a desktop: on a server, or over SSH with no display, the script stops with a UI error.
samples/life-lab/desktop.kscript is a complete example: the Game of Life with a clickable board, a timer and controls, sharing its rules with a terminal and a browser version.