ztk::debug
Gives the source of an option, the geometry chain of a widget, a trace of events and changes, and visual diffs of a window.
Synopsis
ztk::debug sources ?BOOLEAN?
ztk::debug why PATHNAME ?OPTION? ?-all?
ztk::debug geometry PATHNAME
ztk::debug trace start ?-kinds LIST? ?-size N?
ztk::debug trace stop|clear|status
ztk::debug trace records ?-kind LIST? ?-widget PATTERN? ?-match PATTERN? ?-cause N? ?-since N? ?-last N?
ztk::debug mark NAME ?PATHNAME?
ztk::debug diff NAME ?-image? ?-tolerance N?
ztk::debug marks
ztk::debug forget NAME
ztk::debug explain PATHNAME ?OPTION?
ztk::debug click PATHNAME ?BUTTON?
ztk::debug type TEXT ?PATHNAME?
ztk::debug ran ?SEQ?
ztk::debug changes NAME
ztk::debug tree ?PATHNAME?
Arguments
| Name |
Type |
Default |
Meaning |
sources ?BOOLEAN? |
subcommand |
0 |
1 records the call that sets each option. With no value, gives the current state. |
why PATHNAME ?OPTION? |
subcommand |
|
Gives a dict of the source of the option. With no option, gives a list of dicts: one for each option that a call, a style, or a variable set. -all gives each option. |
geometry PATHNAME |
subcommand |
|
Gives a list of dicts, one for each level from the widget up to its toplevel: the requested size, the box, the manager, and notes. |
trace start |
subcommand |
|
Starts a ring of records. -kinds is a list of event, motion, binding, command, option, geometry, dirty, frame, focus, and grab, or all. The default is each kind but motion. -size is 1 to 1000000 records, default 10000. |
trace stop |
subcommand |
|
Stops the trace and keeps the records. |
trace clear |
subcommand |
|
Removes the records. |
trace status |
subcommand |
|
Gives a dict of on, kinds, count, size, and dropped. |
trace records |
subcommand |
|
Gives the records that pass each filter, as a list of dicts. |
mark NAME ?PATHNAME? |
subcommand |
. |
Keeps the image and the widgets of the toplevel of PATHNAME under NAME. |
diff NAME |
subcommand |
|
Compares the mark with the toplevel now and gives a dict of the changes. -image adds a PNG of the changed pixels as base64. -tolerance is the change of a color channel, 0 to 255, that counts as no change (default 0). |
marks |
subcommand |
|
Gives the names of the marks, sorted. |
forget NAME |
subcommand |
|
Removes a mark. An unknown name is no error. |
explain PATHNAME ?OPTION? |
subcommand |
|
Gives the answer of why and geometry as lines of text. |
click PATHNAME ?BUTTON? |
subcommand |
1 |
Clicks the center of the widget and gives, as lines, each event with what it ran and changed. |
type TEXT ?PATHNAME? |
subcommand |
|
Types the text into the widget with the focus, or into PATHNAME after a click on it, and gives the same lines as click. |
ran ?SEQ? |
subcommand |
the last event |
Gives, as lines, what ran for an event of the trace. |
changes NAME |
subcommand |
|
Gives the answer of diff as lines. |
tree ?PATHNAME? |
subcommand |
. |
Gives one line for each widget: the path, the class, the box, and the map state. |
Return value
The value in the table for each subcommand. trace start, trace stop, trace clear, and forget give an empty string. mark gives NAME.
Errors
| Error |
When |
bad window path name "W" |
No widget has the name. |
PATHNAME is not mapped |
click or type of a widget that is not on the screen. |
unknown option "-X" |
why of an option that the widget does not have. |
bad kind in "X": must be event, motion, binding, command, option, geometry, dirty, frame, focus, grab, or all |
An unknown kind of -kinds or -kind. |
bad size "N": must be 1 to 1000000 |
A -size out of range. |
bad option "-X": must be -kinds or -size |
An unknown option of trace start. |
bad option "-X": must be -cause, -kind, -last, -match, -since, or -widget |
An unknown filter of trace records. |
bad option "X": must be clear, records, start, status, or stop |
An unknown subcommand of trace. |
no mark "NAME" |
diff or changes of an unknown mark. |
bad option "-X": must be -image or -tolerance |
An unknown option of diff. |
bad option "X": must be changes, click, diff, explain, forget, geometry, mark, marks, ran, sources, trace, tree, type, or why |
An unknown subcommand. |
| Platform |
Works |
| Windows |
Yes |
| macOS |
Yes |
| Linux, Wayland |
Yes |
| Linux, X11 |
Yes |
| Web |
Yes |
| iOS, Android |
Yes |
| Headless |
Yes |
Example
ztk::debug sources on
button .save -text Save
pack .save
.save configure -state disabled
dict get [ztk::debug why .save -state] source
See also