Skip to content

Switch the Qt binding from PyQt6 to PySide6 - #258

Merged
gbradham merged 6 commits into
devfrom
claude/beautiful-bell-rh3b4z
Nov 29, 2026
Merged

gbradham merged 6 commits into
devfrom
claude/beautiful-bell-rh3b4z

Conversation

@gbradham

@gbradham gbradham commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Fixes LL-72.

Why

PyQt6 is GPL; PySide6 is LGPL. Switching keeps a closed-source, sold GLIDER possible, as long as PySide6 stays a separate, replaceable library and its licence ships with GLIDER.

What changes

  • Imports and APIs. PyQt6 becomes PySide6, pyqtSignal/pyqtSlot become Signal/Slot, and sip.isdeleted becomes shiboken6.isValid. QWIDGETSIZE_MAX is defined locally because PySide6 doesn't export it.
  • Real behaviour differences the tests caught:
    • QPainter.drawPolygon/drawPolyline take one QPolygonF, not separate points. In Session Review this raised mid-paint and later crashed pyqtgraph.
    • QPen takes no cap=/join= keywords (affected the progress bar).
    • The camera panel's status message now goes to the window's own status bar. findChild returned a replaced bar that Qt hadn't deleted yet.
    • Worker-thread signals. Under PySide6, a lambda, closure or partial connected to a signal from a worker thread runs on that thread, even with QueuedConnection; only a bound method of a GUI-thread QObject is queued. A full audit found the risky ones in Behavior Analysis: Apply's finished/failed handlers and the cohort-speed run touched widgets, showed dialogs and started the next thread off the GUI thread. They now use bound methods. The annotator's worker list and retire_thread's parked list are fixed too, the second with a lock. About 57 other connections were already bound methods and are unaffected.
    • Also routed through a signal: the flow engine's node-active callback, which with the opt-in flow loop thread fires on that thread. This was an existing bug, not caused by the switch.
  • Making sure only PySide6 loads. glider/__init__.py sets QT_API and PYQTGRAPH_QT_LIB, so pyqtgraph, matplotlib and qasync can't pick up a leftover PyQt6. An older Pi image has one from apt.
  • Dependencies. PySide6-Essentials>=6.8.0.2 goes in both pc and rpi.
  • Raspberry Pi. Qt now comes from pip, not apt's python3-pyqt6. On Bookworm (glibc 2.36), 6.8.0.2 is the newest PySide6 with a Pi wheel, on Qt 6.8 LTS; later versions need Trixie. install.sh, the Pi image stage and glider-update.sh install the rpi extra and libxcb-cursor0, and the image's pip install now includes [rpi].
  • Tests. pytest-qt runs with qt_api = "pyside6". A new capture_menu_exec fixture is needed because PySide6 ignores QMenu.exec patched onto the class. A few tests were adjusted for PySide6 argument and keyword differences.
  • Docs, changelog and AGENTS.md. The install docs no longer mention apt's PyQt6. AGENTS.md is no longer gitignored and says never to credit or commit as an AI agent.

Testing

  • The full suite, plugins included: 7625 passed, 13 skipped, 0 failed locally (Linux, Python 3.12, PySide6 6.12, offscreen).
  • CI is green on Ubuntu, Windows and macOS, and lint passes.
  • Every module in glider and the plugins imports under PySide6.
  • Not yet done:
    • Clicking through the app by hand on desktop.
    • Running it on a real Pi, with a Bookworm install of PySide6 6.8.0.2.

Compatibility

  • Existing installs need to re-run the installer, or uv sync --extra pc. On a Pi, re-run install.sh or the update script.
  • Saved files are unaffected.

PySide6 is LGPL where PyQt6 is GPL, which keeps a closed-source GLIDER
possible. Imports move to PySide6, pyqtSignal/pyqtSlot become
Signal/Slot, sip.isdeleted becomes shiboken6.isValid, and
QWIDGETSIZE_MAX (not exported by PySide6) is defined locally.

glider/__init__ sets QT_API and PYQTGRAPH_QT_LIB so pyqtgraph,
matplotlib and qasync cannot pick up a leftover PyQt6. The pc and rpi
extras depend on PySide6-Essentials>=6.8.0.2, the newest with a wheel
for Raspberry Pi OS Bookworm; the Pi installer, image and update script
install the rpi extra and libxcb-cursor0 instead of apt's python3-pyqt6.
pytest-qt runs with qt_api = pyside6.
Commit the file (it was gitignored) so cloud sessions, which clone fresh,
follow the rule too.
PyQt6 accepted drawPolygon/drawPolyline with the points as separate
arguments; PySide6 takes a single polygon and raised mid-paint, which
left the canvas half-drawn and later crashed pyqtgraph during garbage
collection.
PySide6 ignores QMenu.exec patched onto the class (exec has static and
instance overloads, and an instance call bypasses the class attribute),
so the real modal menu opened and the hardware-panel test hung. The new
capture_menu_exec fixture swaps the module's QMenu for a subclass whose
exec does the capturing.
- QPen takes no cap=/join= keywords: build round pens with setters.
- The camera panel's status message goes to the window's own status bar;
  findChild returned a replaced bar not yet deleted.
- Tests: QTest's modifier is positional (PySide6 calls it stateKey),
  QAction.disconnect() needs a signal, QImage.bits() is a sized
  memoryview, font().family() is the requested face (use fontInfo), and
  waitSignal on a worker's signal returns before the main-thread slot runs.
Under PySide6 a lambda, closure or partial connected to a signal emitted
on a worker thread runs on that thread, even with QueuedConnection; only
a bound method of a GUI-thread QObject is queued to the GUI thread.
PyQt6 queued lambdas too, so these were safe before and are not now:

- Behavior Analysis Apply: finished/failed tore the thread down, updated
  widgets and started the next video from the worker thread.
- Behavior Analysis cohort speed: progress bar, message box and buttons.
- The annotator's speed-worker bookkeeping raced its stop path.
- retire_thread's release runs on the finishing thread; guard its list.
- The flow engine's node-active callback goes through a signal, since it
  fires on the flow loop thread when that setting is on.

Also corrects the flow_loop docstring, and makes a qthreads test wait for
its worker to start and not time out while the GUI thread is busy.
@gbradham
gbradham marked this pull request as ready for review November 29, 2026 19:27
@gbradham
gbradham merged commit caddd41 into dev Nov 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant