Skip to content

Commit

Permalink
Updated to pySide6 to ease deployment on RPi
Browse files Browse the repository at this point in the history
  • Loading branch information
blauret committed Oct 6, 2023
1 parent 3b654b5 commit c1b6e63
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 55 deletions.
26 changes: 13 additions & 13 deletions pyG5/pyG5Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -34,7 +34,7 @@


class pyG5App(QApplication):
"""pyG5App PyQt6 application.
"""pyG5App PySide6 application.
Args:
sys.argv
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -173,7 +173,7 @@ def argument_parser(self):


class pyG5BaseWindow(QMainWindow):
"""pyG5App PyQt6 application.
"""pyG5App PySide6 application.
Args:
sys.argv
Expand All @@ -182,7 +182,7 @@ class pyG5BaseWindow(QMainWindow):
self
"""

closed = pyqtSignal()
closed = Signal()

def __init__(self, parent=None):
"""g5Widget Constructor.
Expand Down Expand Up @@ -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.
Expand All @@ -273,7 +273,7 @@ def closeEvent(self, event):


class pyG5MainWindow(pyG5BaseWindow):
"""pyG5App PyQt6 application.
"""pyG5App PySide6 application.
Args:
sys.argv
Expand All @@ -282,7 +282,7 @@ class pyG5MainWindow(pyG5BaseWindow):
self
"""

closed = pyqtSignal()
closed = Signal()

def __init__(self, parent=None):
"""g5Widget Constructor.
Expand Down Expand Up @@ -310,7 +310,7 @@ class pyG5SecondWindow(pyG5BaseWindow):
self
"""

closed = pyqtSignal()
closed = Signal()

def __init__(self, parent=None):
"""g5Widget Constructor.
Expand Down
26 changes: 13 additions & 13 deletions pyG5/pyG5Network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -32,7 +32,7 @@ class pyG5NetWorkManager(QObject):
self
"""

drefUpdate = pyqtSignal(dict)
drefUpdate = Signal(dict)

def __init__(self, parent=None):
"""Object constructor.
Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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)
Expand Down Expand Up @@ -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()))
Expand All @@ -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
Expand Down Expand Up @@ -756,7 +756,7 @@ class pyG5MulticastListener(QObject):
self
"""

xpInstance = pyqtSignal(QHostAddress, int)
xpInstance = Signal(QHostAddress, int)

def __init__(self, parent=None):
"""Object constructor.
Expand Down Expand Up @@ -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():
Expand Down
16 changes: 8 additions & 8 deletions pyG5/pyG5View.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
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,
QColor,
QLinearGradient,
QRadialGradient,
)
from PyQt6.QtWidgets import (
from PySide6.QtWidgets import (
QWidget,
QVBoxLayout,
)
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions pyG5/pyG5ViewTester.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down
55 changes: 38 additions & 17 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c1b6e63

Please sign in to comment.