ztk::snapshot
Renders a widget to a PNG image with the CPU renderer and gives the image as base64 text.
Synopsis
ztk::snapshot PATHNAME
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
PATHNAME |
widget path | The widget. The image is the rectangle of the widget in the last frame of its toplevel, in device pixels. |
The command first runs the pending frames, as update does. The image is the same on each backend.
Return value
The PNG image as base64 text. image create photo -data reads it.
Errors
| Error | When |
|---|---|
bad window path name "W" |
No widget has the name, or a script of the frames deleted it. |
window "W" has no visible area |
The widget has no width or no height in the image. |
wrong # args: should be "ztk::snapshot pathName" |
No argument, or more than one. |
Platforms
| Platform | Works |
|---|---|
| Windows | Yes |
| macOS | Yes |
| Linux, Wayland | Yes |
| Linux, X11 | Yes |
| Web | Yes |
| iOS, Android | Yes |
| Headless | Yes |
Example
button .ok -text OK
pack .ok -padx 20 -pady 20
image create photo shot -data [ztk::snapshot .ok]
list [image width shot] [image height shot]