| name | pythonide-widget |
|---|---|
| description | Create or repair PythonIDE iOS Home Screen widgets using widget.Widget(), widget.param, widget.state, charts, tables, canvas layouts, and family branching. Use when the user asks for a WidgetKit widget, desktop widget script, or widget preview — not an AppUI MiniApp. |
| license | MIT |
| version | 1.0.0 |
| last_updated | 2026-06-10 |
| user_invocable | true |
Execution rulebook for Python-first iOS Home Screen widgets.
- Widget module
- Widget schema and widget.pyi
- llms-full.txt widget surface
- Focused guides: layout, parameters, interaction, timeline
Do not use AppUI, SwiftUI, TSX, HTML, or undocumented widget helpers.
- Confirm the user wants a widget, not an AppUI MiniApp (
pythoniderouter). - Write one runnable Python file:
import widget, onewidget.Widget(...), documented primitives,w.render(). - Default target family: medium Home Screen unless the user asks otherwise.
- Use
widget.paramfor preview-sheet tunables; usewidget.statefor desktop interactions. - Branch with
widget.family,widget.family_value(...),w.when(...), orw.unless(...)only when supporting multiple families. - Repair layout issues before claiming completion.
import widget
ctx = widget.context
accent = widget.param.color("Accent", "#34D399")
count = widget.state.int("count", 0)
w = widget.Widget(background=("#F8FAFC", "#0B1220"), style="clean")
w.text("Today", size=16, weight="semibold").line_limit(1).min_scale(0.72)
w.value(count, unit="x").content_transition("numericText").monospaced_digit()
w.progress(min(int(count), 10), total=10, color=accent, height=8)
if ctx.content_height >= 120:
w.button("+1", action=count.increment(), background=accent, color="#FFFFFF")
w.render()- One
widget.Widget()entry per script - Prefer documented primitives:
text,rich_text,value,symbol,svg,image,shape,rect,circle,path,table,line_chart,bar_chart,ring_chart,progress,row,column,layer,grid,region,canvas,button,link,toggle widget.param.color/slider/number/text/bool/choice/filefor preview-editable valueswidget.stateactions:increment(),decrement(),set(value),toggle(),toggle_item(value)- Layout containers use
withblocks:with w.row(spacing=8):then child calls on indented lines - Use
ctx = widget.contextfor size-aware composition insidectx.content_width/ctx.content_height - Add
.line_limit(...)and.min_scale(...)to long text - Widget animations are timeline/state-update animations, not continuous 60fps app loops
| Request | Target |
|---|---|
| Unspecified | medium only |
Explicit small |
one title, one value, one compact visual |
Explicit large |
add real extra content, do not stretch medium |
| All Home Screen sizes | branch per family |
| Accessory families | only when explicitly requested |
- No
appui,scene, oruiin widget deliverables - No invented APIs or compatibility aliases omitted from public schema
- No claiming gradients, network data, charts, or interaction unless coded with documented APIs
- No
w.row(w.text(...), spacing=8)— usewith w.row(...)
| Issue | Fix |
|---|---|
| Blank widget | restore w.render() |
| Cropped text | shorten, branch by family, add .line_limit(1).min_scale(0.6) |
| Crowded medium | remove optional metrics or reduce chart density |
| Table lines too heavy | line_width="hairline" |
| Tap no effect | use widget.state action reference |
| Network failure | cache_json(..., default=...) fallback |
examples/progress/— medium widget with param, state, and progress bar
Widgets are not MiniApps. If the user wants in-app navigation, forms, or multi-screen tools, switch to pythonide-appui.