Kryon Labs Logo

Kryon Labs

TK: Toolkit

TK: Toolkit

TK is a Plan 9-style UI toolkit that provides widget rendering, event handling, layout management, and a complete UI component library. TK implements a synthetic UI filesystem using the 9P2000 protocol — the entire interface is a tree of files.

Synthetic UI Filesystem

TK implements a complete synthetic UI filesystem using the 9P2000 protocol. The entire interface is a tree of files — every widget is a directory, every property is a file, every event is a file read. This "Synthetic UI" approach enables universal deployment through a simple, elegant interface.

Three core principles define TK:

Widget Library

TK provides a comprehensive set of UI widgets:

Dual-Mode Architecture

TK operates in two distinct modes:

TK Dual-Mode Architecture Diagram

CPU Server Mode: Run TK on Linux/Android/BSD with a TCP listener. Drawterm clients connect remotely for network-transparent sessions.

Native Mode: Run TK on 9front with kernel pipes. Integrates directly with rio window management and native graphics.

Code Example

A complete "Hello TK" app demonstrating the synthetic filesystem approach. The same code runs on both modes — CPU Server or Native:

-- controller.lua — Direct 9P filesystem interaction
local tk = require("tk")

# Mount the synthetic UI filesystem
tk.mount("/mnt/tk")

local count = 0

# Create a simple window with label and button
tk.write("/mnt/tk/windows/main/title", "Greeting App")

# Add widgets as directory/file operations
tk.mkdir("/mnt/tk/widgets/greeting")
tk.write("/mnt/tk/widgets/greeting/type", "label")
tk.write("/mnt/tk/widgets/greeting/text", "Awaiting input...")

# Watch for events via file reads
while true do
    local event = tk.read("/mnt/tk/events")
    if event.widget == "submit_btn" then
        count = count + 1
        tk.write("/mnt/tk/widgets/greeting/text",
                     "Hello, " .. event.value .. "!")
    end
end

CLI Tool (tjk)

TK includes a CLI tool called tjk for managing UI components and resources:

# Build and use tjk
$ cd tk
$ mk
$ ./bin/tjk --help

Links

WM (Window Manager) → | Mu (Kernel) → | GitHub Repository | Back to Projects