Desktop applications with HYUI
The Development checkout includes an optional desktop UI host, hyui, and the
Hydrogen-written Hydrogen.UI library. A .hyui file describes the frontend;
Program.hy selects the view and handles events. This is an experimental HYUI v1
API, separate from the published alpha-0.0.2 compiler. It does not change the
development project’s 0.1.0 release qualification milestone.
Build and run
Section titled “Build and run”The build tools use Qt Core 6.8 or newer for XML, processes, and events; Qt Test enables contract tests. Qt does not render the application’s windows or controls. Linux uses system GTK 4 and libadwaita (1.4+); macOS uses AppKit; Windows uses Microsoft’s WinUI 3 and requires the .NET 8+ SDK to build its host. The compiler itself does not require a desktop SDK.
cmake -S . -B build -DHYDROGEN_BUILD_UI=ON -DCMAKE_BUILD_TYPE=Releasecmake --build build --target hy hyui hyui_tests -j 4export PATH="$PWD/build:$PATH"hy build samples/ui_studio/Studio.hyproj -o build/HydrogenStudio
# Double-click HydrogenStudio in your file manager, or run it directly:./build/HydrogenStudio
# A single-file entry point automatically gets the bundled Hydrogen.UI library.hy ui samples/ui_studio/Program.hyFor a project, reference
libraries/Hydrogen.UI/Hydrogen.UI.hyproj through project_references. The host
uses the sibling hy compiler, then hy on PATH. To select a self-hosted compiler,
set HYUI_COMPILER to its absolute path, or invoke
hyui --compiler /path/to/hy --source /path/to/Program.hy.
The native compiler requires hyui on PATH at build time. cmake --install build
installs the host tools and launcher templates. Published compiler archives do not
yet include these development tools.
Building an application you can double-click
Section titled “Building an application you can double-click”Add the entry view to a normal executable project:
format = 2name = "MyApplication"type = "exe"ui = "Views/Main.hyui"ui_assets = ["Assets"]sources = ["Program.hy"]project_references = ["../libraries/Hydrogen.UI/Hydrogen.UI.hyproj"]ui_assets is optional. The entry view is always included. Assets must stay inside
the project directory; traversal paths and symlinks are rejected. The compiler
builds the Hydrogen backend and packages its native host and view automatically:
hy build MyApplication.hyproj -o MyApplicationhy build MyApplication.hyproj --target linux -o MyApplicationhy build MyApplication.hyproj --target windows -o MyApplication.exehy build MyApplication.hyproj --target macos -o MyApplication.appLinux produces an ELF launcher and MyApplication.runtime/; Windows produces a
GUI .exe launcher and MyApplication.exe.runtime/; macOS produces a Finder
.app bundle. Keep the runtime folder beside the executable when copying or
distributing Linux/Windows applications. These are complete application folders,
not single-file static binaries. The executable locates its assets independently
of the terminal’s working directory, and does not invoke hy, compile sources,
or require Hydrogen on the destination device. Ordinary projects without ui
retain their existing build behavior.
Builds stage the package before replacing the output. Invalid XML, missing assets, compiler errors, or a missing target runtime preserve the previous application. Rebuilds only replace runtime directories marked as Hydrogen packages.
The Hydrogen-written direct backends currently emit x86-64 applications.
The C++ SDK’s C backend can emit native macos-arm64 application logic with
Apple’s clang. A cross-build needs both the compiler’s target backend and an exported native runtime
for that platform. Run on the corresponding target system:
hyui --export-runtime /path/to/runtimes/linux-x64# On Windows, with .NET and Windows App SDK development prerequisites:hyui --export-runtime C:/runtimes/windows-x64# On an Intel Mac, with macdeployqt available:hyui --export-runtime /path/to/runtimes/macos-x64.app# On an Apple Silicon Mac, with macdeployqt available:hyui --export-runtime /path/to/runtimes/macos-arm64.app --target macos-arm64Set HYUI_RUNTIME_ROOT to that runtimes directory on the build machine. The native
compiler can then select the matching exported runtime. A missing or mismatched
runtime fails clearly; a Qt Fluent/macOS lookalike is never substituted. The C++
SDK’s backend remains a C route; on macOS, Apple’s clang can target arm64 from
either Intel or Apple Silicon. Use the self-hosted compiler for other
cross-target code generation. Windows runtime export restores/builds the genuine
Microsoft WinUI host using its pinned Windows App SDK dependency.
For an Apple Silicon build from the Development source checkout, use the bootstrap compiler and native AppKit runtime:
cmake -S . -B build/arm64 -DHYDROGEN_BUILD_UI=ON -DCMAKE_BUILD_TYPE=Releasecmake --build build/arm64 --target hy hyui hydrogen-ui-sdk --parallelbuild/arm64/hyui --package samples/ui_studio/Studio.hyproj \ --output build/arm64/Studio --target macos-arm64 \ --compiler build/arm64/hy \ --runtime build/arm64/native-sdk/macos-arm64.appThe Apple Silicon CI job
verified native AppKit interactions, arm64 UI host and Hydrogen backend
architectures, and packaged Studio launch. The published compiler archive does
not include the hyui build tool.
Small application
Section titled “Small application”Program.hy:
using Hydrogen.UI;
class Program { public static int Main(string[] args) { if (!Application.IsEvent(args)) { Application.Open("Main.hyui"); return 0; } if (Application.Handler(args) == "Greet") { Application.SetText("greeting", "Hello, " + Application.Value(args, "name")); } return 0; }}Main.hyui (beside Program.hy):
<Window version="1" title="My Hydrogen app" width="900" height="650"> <Panel title="Welcome"> <RowPanel breakpoint="600"> <Input id="name" placeholder="Your name" accessibleName="Your name" /> <Button id="greet" text="Say hello" onClick="Greet" /> </RowPanel> <Label id="greeting" text="Make yourself at home." /> </Panel></Window>Run hy ui Program.hy. The host compiles the backend to a temporary executable,
runs Main, resolves Application.Open relative to the source directory, and
creates the window. --backend /path/to/executable also supports a precompiled
app: its view is relative to the executable directory, or can be supplied with
--document. Ship the compiled backend and its .hyui files together.
Elements
Section titled “Elements”Common visual-control attributes: id, visible, enabled, fill, preferredWidth, and
accessibleName. IDs are unique identifiers (letters, digits, underscores;
starting with a letter or underscore). Text remains plain text, including backend
responses. Standard XML escaping applies, for example & and .
| Element | Attributes and behavior |
|---|---|
Window |
Required version="1"; title, logical-pixel width/height, padding, theme="system|light|dark", material="auto|glass|solid", onLoad |
ColumnPanel |
Vertical stack; gap |
RowPanel |
Horizontal layout that stacks below its local breakpoint (default 700); gap. Set breakpoint 0 to keep a compact row horizontal. |
GridPanel |
Up to columns (default 3), reducing automatically according to minItemWidth (default 240); gap |
Panel |
Card with optional title, padding, gap; contents stack vertically |
SplitView |
Two visual child panes, native draggable divider; height, pixel-valued value (default 260), onChange |
Label |
text, role="title|heading|body|caption", tone="normal|muted|accent"; wraps to available width |
Input |
text, placeholder, onChange, onSubmit |
TextArea |
text, placeholder, preferred height, onChange; wraps text |
Button |
text, primary, onClick |
ToggleButton |
text, checked, onChange; native stateful press-button, reflected in Hydrogen event snapshots |
CheckBox, Switch |
text, checked, onChange |
ValidationMessage |
text, severity="error|warning|info|success"; native text feedback with severity styling |
StatusBar |
Native status text, text, editable with Hydrogen SetText |
Select |
Pipe-separated items, zero-based selected index value, onChange |
NumberInput, Slider |
Integer value, minimum, maximum, onChange |
ProgressBar |
value, minimum, maximum (defaults 0–100), indeterminate |
Spinner |
running; animated activity indicator |
Separator, Spacer |
Divider or vertical space (height) |
Timer |
interval in milliseconds (minimum 100), running, required onTick |
State |
Nonvisual value available to Hydrogen handlers |
Numeric attributes use nonnegative integers up to 32767. Width, height, columns,
and minimum item width must be positive. Boolean attributes use true/false.
Unknown elements/attributes, duplicate IDs, unsupported versions, malformed XML,
DTD/entities, excessive nesting, and oversized documents fail before a window is
shown. There is no embedded JavaScript, QML, HTML, or shell-script element.
New development controls: stateful buttons and validation feedback
Section titled “New development controls: stateful buttons and validation feedback”The Development compiler’s HYUI control addition PR #196 introduces native ToggleButton and ValidationMessage elements for GTK4, WinUI 3 and AppKit. Both are implemented in Development and passed native GTK4, WinUI 3, AppKit and bootstrap checks in CI run 41843955763. They remain unreleased experimental features until a compiler release includes them.
<ToggleButton id="advanced" text="Enable advanced tools" checked="false" onChange="ToggleAdvanced" /><ValidationMessage id="advancedMessage" severity="info" text="Advanced tools disabled" />A Hydrogen handler can read Application.Value(args, "advanced") as "true" or "false", and update either control using Application.SetChecked or Application.SetText. Severity is fixed in the XML document for v1; the message’s visibility and text can change at runtime.
Resizable IDE panes and status feedback (Development)
Section titled “Resizable IDE panes and status feedback (Development)”The SplitView and StatusBar implementation PR #197 adds two experimental HYUI elements. SplitView accepts exactly two visual children and uses a real GTK4 GtkPaned, AppKit NSSplitView, or WinUI Grid with draggable Thumb. The divider position is a pixel count, available as Application.Value(args, "workspaceSplit") in its onChange handler. Hydrogen can also set the position with Application.SetValue. StatusBar text can be changed with Application.SetText.
<SplitView id="workspaceSplit" value="280" height="320" onChange="PaneResized"> <Panel title="Explorer"><Label text="Project files" /></Panel> <Panel title="Editor"><Label text="Choose a file" /></Panel></SplitView><StatusBar id="workspaceStatus" text="Ready" />These controls are merged and passed GTK4, AppKit, and WinUI interaction jobs in CI run 41876342201, but remain unreleased. Initial SplitView supports the horizontal (left/right) arrangement; vertical splits, nested IDE docking, persistent splitter positions, and closeable editor tabs remain future work.
Updating native list data (Development)
Section titled “Updating native list data (Development)”ListBox.items starts with the pipe-separated labels in the .hyui document.
Hydrogen can replace them from a handler with Application.SetItems("templates", "Notes|Tasks|Photos").
It can set ListBox.value in the same response using Application.SetValue; the
native host validates the final items and selection together, regardless of the
order of the two updates. If a shorter list would remove the current selection,
the host selects its last item. Empty lists and selections outside the new list
are rejected without changing the UI. The selection callback continues to
receive the selected zero-based index through Application.Value(args, id).
This runtime update passed the shared contract suite, native GTK4, AppKit and WinUI interaction and reviewed screenshot jobs, and Stage 1–3 single-file GTK4 generation in CI run 43358715272.
Hierarchical project data (Development)
Section titled “Hierarchical project data (Development)”TreeView accepts items as pipe-separated preorder depth:label rows. Depth
starts at 0 for a root and may increase by one level for each child. A row’s
value is its zero-based position in this preorder list, and onChange reads
that index with Application.Value(args, id). For example:
<TreeView id="files" items="0:Project|1:src|2:Program.hy|1:assets" value="0" height="160" onChange="ChooseFile" />Hydrogen can replace the hierarchy with Application.SetItems("files", "0:Workspace|1:src|2:Main.hy")
and select a row with Application.SetValue("files", 2) in either order in one
handler response. The host validates the final hierarchy and selection before
applying either update. It rejects orphaned depth levels, empty labels, and
explicit selections beyond the new tree; shrinking a tree clamps an existing
selection to its last row. The current format supports up to 512 rows, depth 32,
and 16,384 characters. It does not encode a pipe character inside a label.
The shared contract suite, native GTK4, AppKit and WinUI interaction and reviewed
screenshot jobs, and Stage 1–3 single-file GTK4 generation passed in
CI run 43358715272.
TreeTable, observable and multiple-selection lists, and dynamic child controls
remain open.
Hydrogen handlers and updates
Section titled “Hydrogen handlers and updates”Application.IsEvent(args), Handler(args), and Sender(args) identify the
callback. Application.Value(args, id) returns the control’s text, selected
index, numeric value, checked state, or nonvisual state value. It returns an empty
string for an unknown ID. For numeric values use System.Convert.ToInt32.
Use SetText, SetItems (for ListBox and TreeView), SetValue, SetChecked, SetEnabled, SetVisible, and
SetRunning; Set(id, property, stringValue) also supports indeterminate and
string-valued State.value. A response is validated and applied as one batch;
invalid responses preserve the previous UI state. Only registered control
properties and XML-declared handlers can be used.
Each callback runs the same compiled Hydrogen backend in a fresh process.
Static fields are not persistent application state. Use control values, State,
or explicit backend file storage. The host dispatches asynchronously and serially,
captures the latest values when each queued event starts, and coalesces duplicate
pending events. Do long work as short steps driven by a timer so the UI stays
responsive. Handlers have a 10-second timeout, a 1 MiB stdout limit, a 64 KiB
stderr limit, and a 24000-character value snapshot limit. Errors appear in the
window. Backend arguments use an argument vector, so input text is not shell code.
The Windows host implements the same wire protocol; its rendering and diagnostic
options still need a real Windows validation pass.
The version 1 wire protocol uses tab-separated HYUI OPEN path and
HYUI SET id property value records. Tabs, newlines, carriage returns, and literal
percent signs are escaped as %09, %0A, %0D, %25. Other console output is
ignored by the host. Normal application errors should return a nonzero exit code.
Responsive behavior and platform appearance
Section titled “Responsive behavior and platform appearance”Layouts use available width, rows collapse, grids reduce columns, and the root
view scrolls vertically. Native frameworks handle fonts and display scaling;
the host and compositor constrain windows to the monitor. Test narrow windows,
large system fonts, and multiple monitor configurations. preferredWidth remains
a layout hint rather than a fixed minimum; native backends may allocate space
differently.
| Platform | Actual controls and window chrome |
|---|---|
| GNOME Linux | System GTK 4/libadwaita: GtkEntry, GtkButton, GtkDropDown, GtkSwitch, etc. AdwWindow and AdwHeaderBar provide the real native window controls and follow the system’s button layout. |
| macOS | Real NSWindow, NSButton, NSTextField, NSSwitch, NSProgressIndicator, etc. AppKit supplies the traffic-light buttons. Public NSGlassEffectView is used on macOS 26+, with NSVisualEffectView fallback and Reduce Transparency support. |
| Windows | Real Microsoft.UI.Xaml WinUI 3 controls. The standard Windows caption bar is retained, including its system menu, close, minimise and maximise controls. |
The old Qt Quick/Fusion and Qt-rendered Fluent preview is superseded. Packaged apps do not ship Qt Quick styles. GNOME apps load GTK/libadwaita from the OS rather than bundling a frozen copy, so system toolkit/theme updates reach their controls. GNOME’s native header bar owns window-button rendering and layout. Linux desktops differ; a KDE-specific Qt Widgets/Breeze backend is not implemented yet.
AppKit controls follow the system frameworks. WinUI 3 is Microsoft’s actual toolkit, but Windows App SDK versions are independent of Windows: an OS update alone cannot guarantee every new WinUI appearance. The Windows host uses the shared Windows App Runtime, which must be installed on the destination; the .NET runtime itself is bundled. Microsoft documents this unpackaged WinUI deployment model.
Real Windows and macOS build/rendering, Liquid Glass composition, accessibility, signing/notarisation, and portable distribution remain platform release gates. This desktop host is separate from Australis’s freestanding runtime.
Demo and validation
Section titled “Demo and validation”samples/ui_studio is a functioning project-plan editor: inputs update a summary,
a cancellable timer drives progress, and Save writes the plan and notes to the
requested file. The demo’s progress creates a plan; it does not invoke a compiler
build or implement desktop notifications.
ctest --test-dir build -R '^hyui_' --output-on-failurehyui --document samples/ui_studio/Studio.hyui --validatehyui --source samples/ui_studio/Studio.hyproj --size 1120x900 --screenshot build/studio.pnghyui --source samples/ui_studio/Program.hy --size 360x740 --screenshot build/studio-narrow.pngThe screenshot command captures the actual native application. The host’s
--event Handler:sender and --state-output path.json options support deterministic
integration checks on Linux. GTK tests require a display; run them under
xvfb-run in headless CI. Native GUI tests explicitly skip when no display is
available; Qt Core contract tests still run. Linux screenshot capture can use
GSK_RENDERER=cairo for deterministic software rendering without changing the
toolkit’s native controls.
Local verification on 30 October 2026 passed Qt Core contract tests, SDK and
self-hosted native demo/package integration, relocation to paths containing spaces
and quotes, source-free startup with Hydrogen removed from PATH, real GTK window
captures, callbacks, cancellation, completion, file saving and failure preservation.
The documentation build also passes, and updated native stage 2/3 compiler
binaries have matching SHA-256 hashes. The earlier 29 October standard
hydrogen_stage1 target exceeded its 90-second SDK seed-build timeout on this
host; development validation uses a retained native seed. These are targeted UI
checks, not qualification of the full compiler release suite.
Linux packages depend on the destination’s GTK 4/libadwaita and base C/C++ runtime. Build on the oldest Linux distribution baseline you intend to support; bundling nonvisual Qt Core support does not make a Linux binary compatible with older system ABIs. macOS and Windows builds/rendering remain unverified on this Linux development host.