ztk::wasm::run
Runs a WebAssembly module that uses the interface tk as a ztk app.
Synopsis
ztk::wasm::run FILE
ztk::wasm::run -remote
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
FILE |
file name | The module. The command reads it through a channel, so a file in the mount of a bundled app or below the root folder works. It gives the module the imports of tk, and the WASI imports with no folder, no clock, and no arguments when the module needs them. Then it calls the export app_init. |
|
-remote |
flag | Runs the module that ztk https://HOST/FILE.wasm downloaded, in the sandbox. |
The first call reads the host scripts of the interface and makes the commands ztk::wasm::widget and ztk::wasm::item.
Return value
The result of the export app_init.
Errors
| Error | When |
|---|---|
couldn't open "FILE": no such file or directory |
The file does not exist. |
malformed module: magic header not detected at byte 0 |
The file is no WebAssembly module. |
ztk::wasm::run -remote: the program has no module of a URL |
-remote in a program that downloaded no module. |
wrong # args: should be "ztk::wasm::run file" |
No argument, or more than one. |
Platforms
| Platform | Works |
|---|---|
| Windows | Yes |
| macOS | Yes |
| Linux, Wayland | Yes |
| Linux, X11 | Yes |
| Web | No: the browser build has no ztcl::wasm. |
| iOS, Android | Yes |
| Headless | Yes |
Example
ztk::wasm::run hello.wasm
update
[ztk::wasm::widget name] insert end Tk
[ztk::wasm::widget greet] invoke
[ztk::wasm::widget msg] cget -text