Skip to content
beetlebugorgPublic

About

The GUI toolkit AI can see: Tk rebuilt in Zig on ztcl. Native on macOS (AppKit, Metal), Windows (Win32, Direct3D 12), Linux (Wayland), and the web (WebGPU). Fluid, Tk-compatible, no bloat.

Topics

Resources

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

ztk

Modern Tk for every screen. Write one script. Get a fast, smooth app for desktop, phone, and the web.

Docs and live demos: https://beetlebug.org/ztk/

One script on each screen: the game Lamplighter on its title screen, in a large desktop window and on a small iPhone in the iOS Simulator, in landscape.

One script, three screens: the game Lamplighter, docs/toys/native/lamplighter.tcl, on a desktop, iOS, and Android.

Note

AI agents write the code, the tests, and the docs of this project, on purpose. A person sets the direction. Why

What will you build?

  • A desktop app. Windows, macOS, and Linux apps from one script, shipped as a single file.
  • A phone app. Real native screens on iPhone and Android, in the same Tcl you write for the desktop.
  • A kiosk screen. Full-screen, touch-first apps for status boards, check-in desks, and machine panels.
  • A game or a tool. Canvas, animation, keys, and the mouse. Three games walk you through it.

How it works

You write the same Tcl and Tk commands as always. ztk runs them on a fresh interpreter written in Zig, draws them with each platform's graphics hardware, and lets CSS handle the look. One script covers the desktop, phones, and the web.

On the desktop

The Spreadsheet example in a window: a formula bar, Undo, Copy, and Paste buttons, number formats, and a grid of costs by quarter with totals and percent shares.

A spreadsheet with 10,000 rows and formulas: examples/spreadsheet.tcl.

Two windows side by side. On the left, the Vector example: a tool column, a drawing of a sun over two mountains, and a properties panel. On the right, a status board titled Print farm with three colored tiles and a list of five print jobs with status badges.

A vector drawing tool and a status board: examples/vector.tcl and examples/dashboard.tcl.

Write it once

  • One script, every screen. The same Tk script runs on Linux, macOS, Windows, the web, iOS, and Android.
  • Native controls on phones. On iOS and Android, a script builds its screens from the views of the system: navigation stacks, lists, tabs, pickers, and alerts. The Tk widgets work there too.
  • A modern look. A CSS stylesheet styles each widget, in light and dark.
  • Fast. In zig build bench, a frame with 1,000 widgets uses 0.85 ms of CPU time at the 99th percentile.
  • Other languages. An app in Rust, Go, or JavaScript compiles to WebAssembly and opens a ztk window.

Check it and ship it

  • Made for agents. An agent can see the window, read each widget, and click in it, with no display.
  • Safe to run. An app from a URL runs in a sandbox with no file, network, or process access.
  • One command to ship. ztk bundle writes the app for each desktop and phone platform.
  • No library to install. ztk uses the platform, the ztcl interpreter, and the Zig standard library. The decoders of JPEG and WebP are compiled in.

Install

Platform Install
macOS brew install beetlebugorg/tap/ztk, or the .tar.gz of a release
Linux brew install beetlebugorg/tap/ztk, or the static .tar.gz of a release
Windows The .zip of a release
iOS and Android ztk bundle writes the app from your script: Touch and the screen
Web npm install @beetlebug/ztk

Install has the build from source.

Example

ttk::label .title -text "Hello from ztk"
ttk::entry .name -textvariable name
ttk::button .greet -text "Greet" -style Accent.TButton -command {set msg "Hello, $name!"}
ttk::label .msg -textvariable msg
pack .title .name .greet .msg -padx 12 -pady 4 -anchor w
ttk::style configure Accent.TButton -foreground white -background #2563eb
ztk hello.tcl

Documentation

Why AI-driven

This project is 100% AI-driven, on purpose. AI agents write the code, the tests, and the docs. A person sets the direction.

It is an experiment in how far a project can go when you let go of how software "should" be developed and move as fast as the agents permit. An optimization that was too much work before is a 15-minute change now, so we try each one.

The world changed. Tk looks like a toolkit for people to learn. ztk is for AI. It is for agents.

Status

ztk is experimental, and it is not yet a drop-in Tk. Differences from Tk lists what is missing, such as text peers and the selections of the system. AI coding agents wrote the code and the docs, under human direction. Review the code before you depend on it. The plan has the roadmap, and the issues take bug reports and requests.

Contributing

A contribution starts in a Discussion: a bug with the smallest script that shows it, or an idea with the use that you have for it. A maintainer makes an issue from the Discussion, and an AI agent of the project does the work of the issue. Do not open an issue or a pull request yourself. CONTRIBUTING.md has the steps, and DISCUSSIONS.md has what a discussion of a bug, an idea, or a question must give.

Contact

Write to [email protected] about ztk. Start a Discussion for a bug or a request, and report a security problem as SECURITY.md says.

License

BSD-2-Clause. See LICENSE. ztk has no code of Tk. References credits Tk and the other sources.

About

The GUI toolkit AI can see: Tk rebuilt in Zig on ztcl. Native on macOS (AppKit, Metal), Windows (Win32, Direct3D 12), Linux (Wayland), and the web (WebGPU). Fluid, Tk-compatible, no bloat.

Topics

Resources

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages