Pytincture + DhxPyt
Overview
Build Python-driven UIs with dhxpyt and run them either as full pytincture services or as browser-only apps using the pytincture runtime.
Quick start decisions
- Choose service mode when you need backend routes, BFF calls, auth, or full app delivery.
- Choose standalone mode when you want a single HTML page that runs Python in the browser with no server.
- Use bundled examples to bootstrap: see
references/examples.md.
Task 1: Build a pytincture app (backend + app delivery)
- Create a module with a
MainWindowsubclass and build UI via dhxpyt. - Add any BFF data classes with
@backend_for_frontendand optional@bff_policy. - Call
launch_service(modules_folder=".")so the server can discover your classes. - Run the module and open the generated route (typically
/ClassName).
Start from:
assets/examples/pytincture_app/py_ui.pyassets/examples/pytincture_app/py_ui_data.py
Reference details:
- Read
references/pytincture.mdfor BFF policies and service setup.
Task 2: Build a dhxpyt UI (widgetset-focused)
- Subclass
MainWindow. - Create a layout with
add_layoutand attach widgets to layout cells. - Prefer widget helpers on the layout or window (for example,
add_cardpanel,add_grid,add_form) instead of instantiating widgets directly; this guarantees a valid container is created. - Configure widgets using
*Configclasses or dicts. - Wire event handlers via
.on_*methods on components (for example,toolbar.on_click(...)).
Avoid: CardPanel(..., root="#id") unless you have already created that DOM node with attach_html.
Start from:
assets/examples/dhxpyt_ui/testui.py
Reference details:
- Read
references/dhxpyt.mdfor usage patterns. - Load
references/dhxpyt.htmlwhen you need full widget API specifics.
Task 3: Use pytincture.js in a standalone HTML page
- Use
assets/standalone/index.htmlas the base template. - Embed Python in
<script type="text/python">. - Add optional wheels to
#micropip-libs. - Set
window.pytinctureAutoStartConfigif you need custom widgetlib or Pyodide URLs.
Troubleshooting:
- If the runtime tries to fetch a wheel like
dhxpyt-99.99.99-py3-none-any.whl, it means a placeholder filename was used. Replace it with"dhxpyt"in#micropip-libsor supply a real wheel file in your appcode. - If you see
ComboConfig.__init__() got an unexpected keyword argument 'options', usedatainstead ofoptionsfor combo items (seereferences/dhxpyt/form.html). - If you see
CardPanel: target container not found, make sure the target DOM element exists first, or pass a layout cell ascontainerinstead ofroot(seereferences/dhxpyt/cardpanel.html). - If you see
Tabbar.add_cardpanel() got an unexpected keyword argument 'panel_config', usecardpanel_config=(notpanel_config).
Reference details:
- Read
references/pytincture-runtime.mdfor runtime configuration and manual start.
Resources
references/
references/pytincture.md: service mode + BFF policy patternsreferences/pytincture-runtime.md: standalone runtime setupreferences/dhxpyt.md: dhxpyt usage overviewreferences/dhxpyt.html: full dhxpyt API docsreferences/examples.md: index of bundled example assets
assets/
assets/examples/pytincture_app/: full app exampleassets/examples/dhxpyt_ui/: minimal dhxpyt UI exampleassets/standalone/: browser-only runtime template and JS