Embedding API for host applications, CLI file argument, PNG-default preview#8
Merged
Conversation
Host applications that ship gleplot as a library (e.g. Asymmetry) can now open the editor inside their own QApplication: - gleplot.gui.open_editor(path, *, parent, settings, gle_executable): opens a shown MainWindow without touching app-global identity (name, organization, icon) and without running an event loop; requires an existing QApplication. Lazily re-exported from gleplot.gui so importing the subpackage stays PySide6-free. - MainWindow.open_path(): public wrapper over the File-Open dispatch for embedders. - MainWindow.apply_gle_executable(): session-only GLE-binary override + preview/status refresh, factored out of the GLE Setup accept path so embedders can impose their configured binary without overwriting the user's standalone preference. - gleplot-gui now accepts an optional .gle file argument, opened after show() so modal prompts appear over a visible window; nonexistent paths exit 2 before any QApplication is created; --smoke-test ignores the file argument entirely. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…t-in The raster path has proven more robust than GLE's Cairo SVG backend, so PNG is now the startup render format unconditionally. SVG remains available via View > Vector preview (SVG), and the one-time probe compile that used to run at controller construction now runs on the first opt-in instead — removing a synchronous gle subprocess from every editor startup. A failed probe routes through the existing sticky PNG fallback so the toggle unchecks/disables with the reason rather than silently refusing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…G opt-in Diagnosis of "SVG preview renders but elements are missing/wrong": GLE's Cairo backend implements box/legend occlusion by clipping underlying content out of the box rectangle (multi-subpath <clipPath>), not by painting over it. QtSvg has no real clip-path support, so occluded content bleeds through (or, with partial clipping, vanishes). The SVG file itself is correct — browsers render it faithfully; only the QtSvg preview is wrong. Empirically 100% of Cairo-emitted clip defs are multi-subpath in both affected and visually-fine figures, so no mechanical validation rule can discriminate; instead the View > Vector preview (SVG) toggle now carries a tooltip and shows a status-bar caveat on enable, steering users back to the (default) PNG preview when rendering looks wrong. Co-Authored-By: Claude Fable 5 <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.
What
Three related changes preparing gleplot's editor to serve as the figure editor inside host applications (concretely: Asymmetry, which ships gleplot as a library dependency and now opens exported
.glefigures in this editor in-process).1. Embedding API (
feat)gleplot.gui.open_editor(path=None, *, parent=None, settings=None, gle_executable=None)— opens a shownMainWindowinside an existingQApplication(raisesRuntimeErrorif there is none). Unlikemain(), it never mutates app-global identity (name, organization, app icon — the window icon is set window-locally), and never runs an event loop. Lazily re-exported fromgleplot.guiso importing the subpackage stays PySide6-free.MainWindow.open_path()— public wrapper over the File ▸ Open dispatch for embedders.MainWindow.apply_gle_executable()— session-only GLE-binary override + preview/status refresh, factored out of the GLE Setup accept path, so a host can impose its configured binary without overwriting the user's standalone preference.MainWindow.force_close()— closes without the dirty-document confirmation, for host shutdown (an unanswerable modal would hang a headless test run; pinned by a regression test).gleplot-gui figure.gleopens the file aftershow(); a nonexistent path exits 2 before anyQApplicationis created;--smoke-testignores the file argument entirely.2. PNG-default preview (
fix)The raster path has proven more robust than GLE's Cairo SVG backend, so PNG is now the startup render format unconditionally. SVG remains opt-in via View ▸ Vector preview (SVG); the probe compile that used to run synchronously at every controller construction now runs on the first opt-in instead (one less subprocess at startup). A failed probe routes through the existing sticky PNG fallback so the toggle unchecks/disables with the reason.
3. QtSvg occlusion-clip diagnosis (
docs)Investigating "SVG renders but elements are missing": GLE's Cairo backend implements box/legend occlusion by clipping underlying content out of the box rectangle (multi-subpath
<clipPath>), not by painting over it. QtSvg has no real clip-path support, so occluded content bleeds through (or vanishes, with partial clipping). The SVG file is correct — browsers render it faithfully; only the QtSvg preview is wrong. No mechanical validation rule can catch this (empirically 100% of Cairo clip defs are multi-subpath in affected and visually-fine figures), so the opt-in toggle now carries a tooltip and shows a status-bar caveat steering users back to PNG when rendering looks wrong; the full analysis is inpreview.py's design notes.Reviewer notes
featcommit cuts 1.6.0, which is the version gate Asymmetry's editor integration feature-detects against (gleplot.gui.open_editorpresent → editor opens in-app; absent → legacy static preview).tests/gui/offscreen). New coverage:tests/gui/test_app.py(9 tests: embedding API, app-identity preservation, GLE-override plumbing/non-persistence, CLI paths, open-after-show ordering, force_close) and reworkedtests/gui/test_svg_preview.py(PNG default, opt-in probe, probe-failure fallback, live-render fallback).🤖 Generated with Claude Code