Tk Create
Generate Tk GUI code from a description, validate with the LSP, iterate until
clean.
Steps
- Read
../_prompts/tk_system.md. - Generate the code:
package require Tkfirst;ttk::widgets where they
exist, classic canvas/text/listbox/menu otherwise; grid for anything
non-trivial, and never pack and grid in one effective -in container
while propagation is on; proper .parent.child paths; scrollbars wired
with -yscrollcommand / -command; wm title and wm geometry;
bindings where useful; braced expressions and bodies.
- Before adding behaviour, classify each callback (
after/after cancel,
fileevent, chan event, trace, bind / bindtags, virtual events,
widget command and validation prefixes, wm protocol) and check the
event substitutions and appended arguments it actually receives; build
prefixes with list or namespace code. Images, fonts, menus, and
variable-backed options are resources with lifetimes.
- Write the file and call
mcp__tcl-lsp__analyzewith the contents as
source. Fix errors and warnings — especially TK1001 geometry conflicts,
TK1002 invalid paths, TK1003 unknown options — and re-validate, up to 5
iterations; then report what remains.
- Call
mcp__tcl-lsp__tk_layouton the final source before claiming
anything about the hierarchy or layout: report its certainty and
uncertainty records, never fill dynamic gaps by guessing, and never run
the Tcl or wish as a preview. If the model is partial or unavailable,
say the layout was not verified.
- Report the final status with the widget structure the model confirmed.
$ARGUMENTS