Support text elements for PySide widgets that display text - #191
Merged
Conversation
Implement create_text_element() and set_element_text() in the PySideRenderer with a TextElementProxy object that holds the text content. Widgets that support text elements as children (QLabel and QAbstractButton subclasses) register insert/remove handlers that keep an ordered list of proxies on the parent widget and display the joined content through setText(). Fixes #189 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
berendkleinhaneveld
added a commit
that referenced
this pull request
Jul 7, 2026
Document the new PySide text element support (#191): update the renderer-support note in the template syntax guide, add a Text Content section to the PySide renderer page, and switch the counter examples to text interpolation to match examples/pyside/counter.cgx. Document the --show-code CLI flag and the CGX_DEBUG environment variable (#175) on the CLI page. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
berendkleinhaneveld
added a commit
that referenced
this pull request
Jul 7, 2026
* Add MkDocs documentation with GitHub Pages deployment
- Set up MkDocs with Material theme (mkdocs.yml, docs dependency group)
- Add GitHub Actions workflow for building and deploying to GitHub Pages
- Write documentation covering getting started, guide, renderers, reference, and examples
- Add site/ to .gitignore
* Update docs for text interpolation, pygfx text elements, and tree view features
Document features merged from master: text expressions with {{ }} in
element content, pygfx <text> element support (text/markdown attributes,
child text nodes), keyed list reconciliation behavior, and PySide tree
view drag-and-drop with preserved selection/expansion state. Add the new
landmarks, keyed tree, and tree DnD examples to the example pages.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Update docs for PySide text elements and --show-code/CGX_DEBUG
Document the new PySide text element support (#191): update the
renderer-support note in the template syntax guide, add a Text Content
section to the PySide renderer page, and switch the counter examples to
text interpolation to match examples/pyside/counter.cgx.
Document the --show-code CLI flag and the CGX_DEBUG environment
variable (#175) on the CLI page.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Update actions in docs workflow to match the other pipelines
Bump checkout to v7, setup-python to v6, and pin setup-uv to the same
sha (v8.3.0) as ci.yml and benchmark.yml. Bump upload-pages-artifact
and deploy-pages to v5.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Merged
berendkleinhaneveld
added a commit
that referenced
this pull request
Jul 21, 2026
Features: - Add pure-Python view API as alternative to cgx templates (#193) - Support text elements for PySide widgets that display text (#191) Fixes & internals: - Fragment parenting overhaul (#162) - Fix PyInstaller hook for CGX files inside packages (#184) - Write compiled AST to temp file when CGX_DEBUG is set (#175) Performance: - Speed up mount path: cheap arity check, reuse first(), leaner emit (#186) - Cache Fragment._component_parent() lookups (#187) - Avoid redundant anchor lookups in Fragment.anchor() and unkeyed v-for (#188) Documentation: - Add MkDocs documentation with GitHub Pages deployment (#176) - Add internals architecture documentation page (#194) - Add docs badge and links to README (#192) Tooling & CI: - Add benchmark suite and per-PR benchmark CI workflow (#185) - Make benchmark CI guard robust against run-to-run noise (#196) - Update GitHub actions from Node 20 to Node 24 (#190) - Migrate from pre-commit to prek (#195) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
create_text_element()andset_element_text()inPySideRendererwith a lightweightTextElementProxythat holds text content and a weakref to its parent widgetinsert/removehandlers forQLabelandQAbstractButton(coversQPushButton,QRadioButton,QCheckBox,QToolButton) that keep an ordered, anchor-aware list of proxies on the parent and display the joined content throughsetText()textattributesThis makes templates like the following work:
The approach follows #181 (pygfx text elements), but instead of type checks in the renderer's generic
insert()/remove()paths, support is opted into per widget type through the existingregister_insert/register_removemachinery. This keeps the generic paths free of feature-specific branches, makes it explicit which widgets support child text, and lets custom widgets add support the same way (seepyside/objects/textelement.py). Inserting text into a widget without registered support logs an error, like other unsupported inserts.Note: since the proxies sync their joined content through
setText(), child text overwrites atext="..."attribute set on the same widget — last writer wins.Fixes #189
Test plan
tests/pyside/test_pyside_text_elements.py: direct renderer tests (label/button text, updates, removal restoring empty text, anchor ordering, unsupported parent) and SFC integration tests (reactive updates via button click,v-ifunmount clearing text)examples/pyside/counter.cgxverified end-to-end offscreen: renders "Count: 0", click updates to "Count: 1"🤖 Generated with Claude Code