From c1b6e639f966935747ef6c1bef45c06c889fbacf Mon Sep 17 00:00:00 2001 From: Ben Lauret Date: Fri, 6 Oct 2023 14:45:47 +0200 Subject: [PATCH] Updated to pySide6 to ease deployment on RPi --- pyG5/pyG5Main.py | 26 ++++++++++---------- pyG5/pyG5Network.py | 26 ++++++++++---------- pyG5/pyG5View.py | 16 ++++++------ pyG5/pyG5ViewTester.py | 6 ++--- requirements.txt | 55 +++++++++++++++++++++++++++++------------- setup.py | 2 +- 6 files changed, 76 insertions(+), 55 deletions(-) diff --git a/pyG5/pyG5Main.py b/pyG5/pyG5Main.py index a9643a7..4b1e702 100644 --- a/pyG5/pyG5Main.py +++ b/pyG5/pyG5Main.py @@ -13,18 +13,18 @@ import platform -from PyQt6.QtCore import ( +from PySide6.QtCore import ( Qt, QTimer, QCoreApplication, QSettings, - pyqtSlot, + Slot, QByteArray, - pyqtSignal, + Signal, QEvent, ) -from PyQt6.QtGui import QFont, QFontDatabase, QCloseEvent, QAction -from PyQt6.QtWidgets import ( +from PySide6.QtGui import QFont, QFontDatabase, QCloseEvent, QAction +from PySide6.QtWidgets import ( QApplication, QMainWindow, ) @@ -34,7 +34,7 @@ class pyG5App(QApplication): - """pyG5App PyQt6 application. + """pyG5App PySide6 application. Args: sys.argv @@ -83,7 +83,7 @@ def __init__(self): ) # Let the interpreter run each 500 ms. self.paintTimer.start(25) # You may change this if you wish. - # The QWidget widget is the base class of all user interface objects in PyQt6. + # The QWidget widget is the base class of all user interface objects in PySide6. self.mainWindow = pyG5MainWindow() self.networkManager.drefUpdate.connect( @@ -173,7 +173,7 @@ def argument_parser(self): class pyG5BaseWindow(QMainWindow): - """pyG5App PyQt6 application. + """pyG5App PySide6 application. Args: sys.argv @@ -182,7 +182,7 @@ class pyG5BaseWindow(QMainWindow): self """ - closed = pyqtSignal() + closed = Signal() def __init__(self, parent=None): """g5Widget Constructor. @@ -251,7 +251,7 @@ def loadSettings(self): logging.warning("State restore: {}".format(inst)) pass - @pyqtSlot(QCloseEvent) + @Slot(QCloseEvent) def closeEvent(self, event): """Close event overload. @@ -273,7 +273,7 @@ def closeEvent(self, event): class pyG5MainWindow(pyG5BaseWindow): - """pyG5App PyQt6 application. + """pyG5App PySide6 application. Args: sys.argv @@ -282,7 +282,7 @@ class pyG5MainWindow(pyG5BaseWindow): self """ - closed = pyqtSignal() + closed = Signal() def __init__(self, parent=None): """g5Widget Constructor. @@ -310,7 +310,7 @@ class pyG5SecondWindow(pyG5BaseWindow): self """ - closed = pyqtSignal() + closed = Signal() def __init__(self, parent=None): """g5Widget Constructor. diff --git a/pyG5/pyG5Network.py b/pyG5/pyG5Network.py index df3e998..ceb5c6f 100644 --- a/pyG5/pyG5Network.py +++ b/pyG5/pyG5Network.py @@ -11,11 +11,11 @@ import os from datetime import datetime as datetime_, timedelta -from PyQt6.QtCore import QObject, pyqtSlot, pyqtSignal, QTimer +from PySide6.QtCore import QObject, Slot, Signal, QTimer -from PyQt6.QtNetwork import QUdpSocket, QHostAddress, QAbstractSocket +from PySide6.QtNetwork import QUdpSocket, QHostAddress, QAbstractSocket -from PyQt6 import QtGui +from PySide6 import QtGui class pyG5NetWorkManager(QObject): @@ -32,7 +32,7 @@ class pyG5NetWorkManager(QObject): self """ - drefUpdate = pyqtSignal(dict) + drefUpdate = Signal(dict) def __init__(self, parent=None): """Object constructor. @@ -633,7 +633,7 @@ def __init__(self, parent=None): QHostAddress.SpecialAddress.AnyIPv4, 0, QUdpSocket.BindFlag.ShareAddress ) - @pyqtSlot() + @Slot() def write_data_ref(self, path, data): """Idle timer expired. Trigger reconnection process.""" cmd = b"DREF\x00" # DREF command @@ -643,7 +643,7 @@ def write_data_ref(self, path, data): if self.xpHost: self.udpSock.writeDatagram(message, self.xpHost, self.xpPort) - @pyqtSlot() + @Slot() def reconnect(self): """Idle timer expired. Trigger reconnection process.""" self.logger.info("Connection Timeout expired") @@ -656,7 +656,7 @@ def reconnect(self): os.system("xset s on") os.system("xset s 1") - @pyqtSlot(QHostAddress, int) + @Slot(QHostAddress, int) def xplaneConnect(self, addr, port): """Slot connecting triggering the connection to the XPlane.""" self.listener.xpInstance.disconnect(self.xplaneConnect) @@ -687,7 +687,7 @@ def xplaneConnect(self, addr, port): os.system("xset s reset") os.system("xset s off") - @pyqtSlot() + @Slot() def socketStateHandler(self): """Socket State handler.""" self.logger.info("socketStateHandler: {}".format(self.udpSock.state())) @@ -706,7 +706,7 @@ def socketStateHandler(self): QHostAddress.SpecialAddress.AnyIPv4, 0, QUdpSocket.BindFlag.ShareAddress ) - @pyqtSlot() + @Slot() def dataHandler(self): """dataHandler.""" # data received restart the idle timer @@ -756,7 +756,7 @@ class pyG5MulticastListener(QObject): self """ - xpInstance = pyqtSignal(QHostAddress, int) + xpInstance = Signal(QHostAddress, int) def __init__(self, parent=None): """Object constructor. @@ -788,17 +788,17 @@ def __init__(self, parent=None): if not self.udpSock.joinMulticastGroup(self.XPAddr): logging.error("Failed to join multicast group") - @pyqtSlot(QAbstractSocket.SocketState) + @Slot(QAbstractSocket.SocketState) def stateChangedSlot(self, state): """stateChangedSlot.""" self.logger.debug("Sock new state: {}".format(state)) - @pyqtSlot() + @Slot() def connectedSlot(self): """connectedSlot.""" self.logger.debug("udp connected: {}".format(self.udpSock.state())) - @pyqtSlot() + @Slot() def udpData(self): """udpData.""" while self.udpSock.hasPendingDatagrams(): diff --git a/pyG5/pyG5View.py b/pyG5/pyG5View.py index aec0460..dc22108 100644 --- a/pyG5/pyG5View.py +++ b/pyG5/pyG5View.py @@ -9,17 +9,17 @@ from math import cos, radians, sin, sqrt, floor from functools import wraps -from PyQt6.QtCore import ( +from PySide6.QtCore import ( QLine, QPoint, QPointF, QRectF, QLineF, Qt, - pyqtSlot, - pyqtSignal, + Slot, + Signal, ) -from PyQt6.QtGui import ( +from PySide6.QtGui import ( QBrush, QPainter, QPolygonF, @@ -27,7 +27,7 @@ QLinearGradient, QRadialGradient, ) -from PyQt6.QtWidgets import ( +from PySide6.QtWidgets import ( QWidget, QVBoxLayout, ) @@ -216,7 +216,7 @@ def setPen(self, width, color, style=Qt.PenStyle.SolidLine): pen.setStyle(style) self.qp.setPen(pen) - @pyqtSlot(dict) + @Slot(dict) def drefHandler(self, retValues): """Handle the DREF update.""" for idx, value in retValues.items(): @@ -253,8 +253,8 @@ def getNavTypeString(self, navType, navIndex): class pyG5SecondaryWidget(pyG5Widget): """Generate G5 wdiget view.""" - xpdrCodeSignal = pyqtSignal(int) - xpdrModeSignal = pyqtSignal(int) + xpdrCodeSignal = Signal(int) + xpdrModeSignal = Signal(int) def __init__(self, parent=None): """g5Widget Constructor. diff --git a/pyG5/pyG5ViewTester.py b/pyG5/pyG5ViewTester.py index da5fffd..7c87119 100644 --- a/pyG5/pyG5ViewTester.py +++ b/pyG5/pyG5ViewTester.py @@ -6,8 +6,8 @@ import sys -from PyQt6.QtCore import Qt -from PyQt6.QtWidgets import ( +from PySide6.QtCore import Qt +from PySide6.QtWidgets import ( QApplication, QHBoxLayout, QGridLayout, @@ -21,7 +21,7 @@ QScrollArea, ) -from PyQt6.QtGui import QKeySequence, QAction +from PySide6.QtGui import QKeySequence, QAction from pyG5.pyG5View import pyG5DualStackFMA, g5Width, g5Height, pyG5SecondaryWidget diff --git a/requirements.txt b/requirements.txt index 6fd7f7b..1939b54 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,24 +1,45 @@ -backports.entry-points-selectable==1.2.0 +ajsonrpc==1.2.0 +anyio==4.0.0 +bottle==0.12.25 +certifi==2023.7.22 cfgv==3.4.0 -codespell==2.2.5 +charset-normalizer==3.3.0 +click==8.1.7 +colorama==0.4.6 distlib==0.3.7 +ezFlashCLI==1.0.18 filelock==3.12.4 -flake8==6.1.0 -flake8-docstrings==1.7.0 -identify==2.5.29 -isort==5.12.0 -mccabe==0.7.0 +h11==0.14.0 +identify==2.5.30 +idna==3.4 +marshmallow==3.20.1 nodeenv==1.8.0 -platformdirs==3.10.0 +packaging==23.1 +platformdirs==3.11.0 +platformio==6.1.11 pre-commit==3.4.0 -pycodestyle==2.11.0 -pydocstyle==6.3.0 -pyflakes==3.1.0 -PyQt6==6.5.2 -PyQt6-Qt6==6.5.2 -PyQt6-sip==13.5.2 +pyelftools==0.29 +PyQt3D==5.15.6 +PyQt5==5.15.9 +PyQt5-sip==12.12.1 +PyQtChart==5.15.6 +PyQtDataVisualization==5.15.5 +PyQtNetworkAuth==5.15.5 +PyQtPurchasing==5.15.5 +PyQtWebEngine==5.15.6 +pyserial==3.5 +PySide6==6.5.3 +PySide6-Addons==6.5.3 +PySide6-Essentials==6.5.3 PyYAML==6.0.1 -six==1.16.0 -snowballstemmer==2.2.0 -toml==0.10.2 +requests==2.31.0 +semantic-version==2.10.0 +shiboken6==6.5.3 +sniffio==1.3.0 +starlette==0.31.1 +tabulate==0.9.0 +urllib3==2.0.5 +uvicorn==0.23.2 virtualenv==20.24.5 +wsproto==1.2.0 +zopfli==0.2.3 diff --git a/setup.py b/setup.py index c2a996d..95d014d 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ # commented out due to impossibility # to install PyQt5 automatically from pip on Raspbian # requirements = ["PyQt5"] -requirements = ["PyQt6"] +requirements = ["PySide6"] test_requirements = [ # TODO: put package test requirements here