migrate pyqt5 to pyside6

This commit is contained in:
ykcheungab
2026-09-21 09:34:56 +08:00
parent e276b5de0f
commit ccedb9ddd9
66 changed files with 2184 additions and 395 deletions
+4 -1
View File
@@ -9,7 +9,10 @@ description = "Shared paths, prefs, theme, i18n, and logging for orisys-app"
requires-python = ">=3.10"
authors = [{ name = "Orisys-Tech" }]
dependencies = [
"PyQt5>=5.15",
# Shared by both apps, which are PySide6-only (LGPLv3). `theme/qss.py` paints the chevron
# icons with it; nothing here may import another binding — enforced by
# apps/autocal/tests/test_binding_purity.py and apps/studio/tests/test_binding_purity.py.
"PySide6>=6.6",
"opencv-python-headless>=4.10.0.84,<5",
"numpy>=1.24.4",
"scipy>=1.10.1",
+6 -6
View File
@@ -33,8 +33,8 @@ def _arrow_icon_cache_dir() -> Path:
def _paint_arrow(kind: str, fill: str) -> str:
"""Draw a small chevron PNG on demand; return its path ('' on failure)."""
try:
from PyQt5.QtCore import QPointF, Qt
from PyQt5.QtGui import QColor, QImage, QPainter, QPolygonF
from PySide6.QtCore import QPointF, Qt
from PySide6.QtGui import QColor, QImage, QPainter, QPolygonF
except Exception: # pragma: no cover - headless import failure
return ""
try:
@@ -43,12 +43,12 @@ def _paint_arrow(kind: str, fill: str) -> str:
path = _arrow_icon_cache_dir() / f"chevron_{kind}_{safe}.png"
if path.is_file():
return str(path)
image = QImage(size, size, QImage.Format_ARGB32)
image.fill(Qt.transparent)
image = QImage(size, size, QImage.Format.Format_ARGB32)
image.fill(Qt.GlobalColor.transparent)
painter = QPainter(image)
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
painter.setBrush(QColor(fill))
painter.setPen(Qt.NoPen)
painter.setPen(Qt.PenStyle.NoPen)
half = size / 2.0
top = size * 0.32
bottom = size * 0.68
+3 -1
View File
@@ -464,6 +464,8 @@ def test_the_contract_layer_imports_without_qt_or_opengl():
Checked in a **fresh interpreter**: asking ``sys.modules`` in this process only
proves what some earlier test happened to import (it failed once the studio tests
painted a widget before this file ran, which says nothing about the contract layer).
The Qt name checked is the binding the app uses (PySide6), which is the only one that
could be pulled in — the earlier spelling named PyQt5, before the migration.
"""
import subprocess
import sys
@@ -471,7 +473,7 @@ def test_the_contract_layer_imports_without_qt_or_opengl():
script = (
"import sys;"
"import orisys_app_shared.scene3d.contracts as c;"
"print(','.join(m for m in ('OpenGL', 'PyQt5', 'cv2') if m in sys.modules))"
"print(','.join(m for m in ('OpenGL', 'PySide6', 'cv2') if m in sys.modules))"
)
result = subprocess.run(
[sys.executable, "-c", script],