Skip to content

Commit dd98467

Browse files
Refactor codebase to migrate from PyQt5 to QtPy and PySide2 (#104)
1 parent 35de475 commit dd98467

22 files changed

Lines changed: 128 additions & 627 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
check-style:
1111
name: Find Trailing Whitespace
12-
runs-on: ubuntu-22.04
12+
runs-on: ubuntu-24.04
1313
steps:
1414
- uses: actions/checkout@v4
1515
- name: Find Trailing Whitespace
@@ -23,42 +23,3 @@ jobs:
2323
exit 1
2424
fi
2525
exit 0
26-
27-
build:
28-
name: Generate python files from ui
29-
runs-on: ubuntu-22.04
30-
steps:
31-
- uses: actions/checkout@v4
32-
- name: Remove broken apt repos [Ubuntu]
33-
run: |
34-
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
35-
- name: Dependencies [Ubuntu]
36-
run: |
37-
sudo apt update
38-
sudo apt install -y pyqt5-dev-tools
39-
- name: Generate python files
40-
run: |
41-
bash ./generate-ui.sh
42-
43-
- name: Archive artifacts
44-
uses: actions/upload-artifact@v4
45-
with:
46-
name: autogenerated_files
47-
path: robot_log_visualizer/ui/autogenerated
48-
49-
deploy:
50-
runs-on: ubuntu-22.04
51-
needs: [build]
52-
if: github.ref == 'refs/heads/main'
53-
steps:
54-
- uses: actions/checkout@v4
55-
56-
- name: Download artifacts
57-
uses: actions/download-artifact@v4
58-
with:
59-
name: autogenerated_files
60-
path: robot_log_visualizer/ui/autogenerated
61-
- name: Deploy
62-
uses: stefanzweifel/git-auto-commit-action@v5
63-
with:
64-
commit_message: ⚙️ Automatic update of the python UI classes

generate-ui.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

robot_log_visualizer/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import os
2+
3+
# Prefer the PySide6 backend when QtPy resolves the Qt binding.
4+
os.environ.setdefault("QT_API", "pyside2")

robot_log_visualizer/__main__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import sys
88

99
# GUI
10+
from qtpy.QtWidgets import QApplication
1011
from robot_log_visualizer.ui.gui import RobotViewerMainWindow
11-
from PyQt5.QtWidgets import QApplication
1212

1313
# Meshcat
1414
from robot_log_visualizer.robot_visualizer.meshcat_provider import MeshcatProvider
@@ -36,7 +36,11 @@ def main():
3636
# show the main window
3737
gui.show()
3838

39-
return app.exec_()
39+
exec_method = getattr(app, "exec", None)
40+
if exec_method is None:
41+
exec_method = app.exec_
42+
43+
return exec_method()
4044

4145

4246
if __name__ == "__main__":

robot_log_visualizer/plotter/pyqtgraph_viewer_canvas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import numpy as np
1010
import pyqtgraph as pg # type: ignore
11-
from PyQt5 import QtCore, QtWidgets # type: ignore
11+
from qtpy import QtCore, QtWidgets # type: ignore
1212

1313
from robot_log_visualizer.plotter.color_palette import ColorPalette
1414
from robot_log_visualizer.signal_provider.signal_provider import ProviderType

robot_log_visualizer/robot_visualizer/meshcat_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import idyntree.swig as idyn
1111
import numpy as np
1212
from idyntree.visualize import MeshcatVisualizer
13-
from PyQt5.QtCore import QMutex, QMutexLocker, QThread
13+
from qtpy.QtCore import QMutex, QMutexLocker, QThread
1414

1515
from robot_log_visualizer.utils.utils import PeriodicThreadState
1616

robot_log_visualizer/signal_provider/realtime_signal_provider.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import time
66
import traceback
77
from collections import deque
8+
from typing import Iterable, Union
89

910
import numpy as np
1011

@@ -117,7 +118,7 @@ def __init__(self, period: float, signal_root_name: str):
117118
self.buffered_signals.add("robot_realtime::joints_state::positions")
118119

119120
# TODO: implement a logic to remove signals that are not needed anymore
120-
def add_signals_to_buffer(self, signals: list | set | str):
121+
def add_signals_to_buffer(self, signals: Union[str, Iterable[str]]):
121122
"""Add signals to the buffer set."""
122123
if isinstance(signals, str):
123124
signals = {signals}

robot_log_visualizer/signal_provider/signal_provider.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import h5py
1010
import idyntree.swig as idyn
1111
import numpy as np
12-
from PyQt5.QtCore import QMutex, QMutexLocker, QThread, pyqtSignal
12+
from qtpy.QtCore import QMutex, QMutexLocker, QThread, Signal
13+
14+
pyqtSignal = Signal
1315

1416
from robot_log_visualizer.utils.utils import PeriodicThreadState, RobotStatePath
1517

robot_log_visualizer/ui/autogenerated/__init__.py

Whitespace-only changes.

robot_log_visualizer/ui/autogenerated/about.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)