Develop on Windows
This page is the loop of a developer on Windows: run a script, choose the renderer, find a bug, test the window, and make a signed program.
Run a script
ztk app.tcl
The program runs until the last window closes or the script calls exit. After you change the script, close the window and run the command again.
| Output | Where it goes |
|---|---|
puts |
The terminal. |
An error in a binding or a -command |
The terminal. The window stays open. |
| An error in the main script | The terminal. The program ends with the status 1. |
The ztk program has each flag, and Quick start has a first script with a style sheet.
The renderer
ztk draws with Direct3D 12 on the first hardware GPU. With no Direct3D 12 device, it draws with the CPU renderer. The variable ZTK_RENDERER chooses:
ZTK_RENDERER |
Output |
|---|---|
| (not set) | Direct3D 12, or the CPU renderer when the machine has no Direct3D 12 device. |
d3d12 |
Direct3D 12 only. The program stops when no device exists. |
warp |
Direct3D 12 on WARP, the software rasterizer of Windows. |
cpu |
The CPU renderer, with SetDIBitsToDevice. |
$env:ZTK_RENDERER = "warp"; ztk app.tcl
Find a bug
ztk::debug tells you why a widget looks or acts as it does. It gives the source of each option, the geometry chain of a size, and what ran for a click.
ztk::debug sources on
ttk::button .ok -text Save
pack .ok
.ok configure -state disabled
puts [ztk::debug why .ok -state]
The output names the line that set the option. Debugging has each tool, and ztk --mcp app.tcl gives them to an agent.
Test the window
A test drives the window with ztk::inject and reads it with ztk::tree. It runs with --headless, so the same test runs on Windows and in CI on Linux.
ztk --headless test.tcl
For agents has a test that clicks a button and checks the count. A headless picture has the look of ztk on Linux: the headless program has no Fluent theme and no DirectWrite.
Make a program
ztk bundle writes one program file, a copy of ztk.exe with the scripts in it:
ztk bundle -o notes.exe --icon notes.png --name "Notes" --version 1.2 notes.tcl lib/ images/
The program has the resources of a Windows app:
| Resource | From |
|---|---|
| The icon of the file and of its windows | --icon: an .ico, or a .png of 256 pixels or less. |
| The version information in the properties of the file | --name and --version. |
| A manifest with per-monitor DPI and the common controls 6 | Each program. |
The program uses the GUI subsystem, so it opens no console window. Started from a terminal, it writes puts and its errors to that terminal. --console gives a program with a console window of its own.
The program reads no flag: each word of its command line goes to $argv. --allow of ztk bundle sets its capabilities, and the default is file,channels. ztk bundle --strip makes a smaller program with only the parts that the scripts use (A smaller app).
A Linux or a macOS computer can also make a Windows program: give --target x86_64-windows or --target aarch64-windows, and the Windows program of that target with --runner or in lib/ztk/runtime/TARGET/ next to ztk.
Sign the program
Windows warns before it runs an unsigned program from the internet. ztk bundle signs the program with Authenticode from any host, with no signtool:
ztk bundle -o notes.exe --sign-cert signer.pem --sign-key signer-key.pem notes.tcl
| File | What it has |
|---|---|
--sign-cert |
PEM: the certificate of the signer first, then the rest of its chain. |
--sign-key |
PEM with no password: a P-256, P-384, or RSA key. |
The signature has no timestamp, so Windows accepts it only while the certificate is valid.
The next page, Widgets, shows how the widgets look and act on Windows.