Skip to content

Commit

Permalink
Convert to PyQt6
Browse files Browse the repository at this point in the history
  • Loading branch information
tomba committed Aug 13, 2024
1 parent 171dd09 commit 3a967a5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint numpy PyQt5 ipython
pip install pylint numpy PyQt6 ipython
git clone --depth=1 https://github.com/tomba/pykms.git ../pykms
- name: Analysing the code with pylint
run: |
Expand Down
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-allow-list=PyQt5
extension-pkg-allow-list=PyQt6

# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
Expand Down
26 changes: 13 additions & 13 deletions utils/cam-rx.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import traceback

from cam_rx_helpers import data_to_pix
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtCore import Qt
import PyQt5.QtNetwork
from PyQt6 import QtCore, QtWidgets
from PyQt6.QtCore import Qt
import PyQt6.QtNetwork

PORT = 43242
receivers = []
Expand Down Expand Up @@ -73,7 +73,7 @@ def meta_to_pix(fmt, w, h, bytesperline, data):


class Receiver(QtWidgets.QWidget):
def __init__(self, socket: PyQt5.QtNetwork.QTcpSocket):
def __init__(self, socket: PyQt6.QtNetwork.QTcpSocket):
super().__init__()

self.name = '{}:{}'.format(socket.peerAddress().toString(), socket.peerPort())
Expand All @@ -84,7 +84,7 @@ def __init__(self, socket: PyQt5.QtNetwork.QTcpSocket):

self.socket.readyRead.connect(self.on_ready_read)
self.socket.disconnected.connect(self.on_disconnected)
self.socket.error.connect(self.on_error)
self.socket.errorOccurred.connect(self.on_error)

self.header_buffer = bytearray()
self.data_buffer = bytearray()
Expand All @@ -93,8 +93,8 @@ def __init__(self, socket: PyQt5.QtNetwork.QTcpSocket):
self.state = 0

self.resize(1000, 600)
self.setAttribute(Qt.WA_ShowWithoutActivating)
self.setWindowFlag(Qt.WindowStaysOnTopHint, True)
self.setAttribute(Qt.WidgetAttribute.WA_ShowWithoutActivating)
self.setWindowFlag(Qt.WindowType.WindowStaysOnTopHint, True)

self.gridLayout = QtWidgets.QGridLayout()
self.setLayout(self.gridLayout)
Expand Down Expand Up @@ -142,7 +142,7 @@ def on_buffers(self):

if idx not in self.labels:
label = QtWidgets.QLabel()
label.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
label.setSizePolicy(QtWidgets.QSizePolicy.Policy.Ignored, QtWidgets.QSizePolicy.Policy.Ignored)
self.labels[idx] = label
self.gridLayout.addWidget(label, self.gridLayout.count() // 2, self.gridLayout.count() % 2)

Expand Down Expand Up @@ -173,7 +173,7 @@ def on_error(self):


def new_connection(tcpServer):
clientConnection: PyQt5.QtNetwork.QTcpSocket = tcpServer.nextPendingConnection()
clientConnection: PyQt6.QtNetwork.QTcpSocket = tcpServer.nextPendingConnection()
w = Receiver(clientConnection)
receivers.append(w)

Expand All @@ -188,11 +188,11 @@ def readkey():
qApp = QtWidgets.QApplication(sys.argv)
qApp.setQuitOnLastWindowClosed(False)

keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)
keynotif.activated.connect(readkey)

tcpServer = PyQt5.QtNetwork.QTcpServer(qApp)
tcpServer.listen(PyQt5.QtNetwork.QHostAddress('0.0.0.0'), PORT)
tcpServer = PyQt6.QtNetwork.QTcpServer(qApp)
tcpServer.listen(PyQt6.QtNetwork.QHostAddress('0.0.0.0'), PORT)
tcpServer.newConnection.connect(lambda: new_connection(tcpServer))

sys.exit(qApp.exec_())
sys.exit(qApp.exec())
2 changes: 1 addition & 1 deletion utils/cam_rx_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Debayering code from PiCamera documentation

from numpy.lib.stride_tricks import as_strided
from PyQt5 import QtGui
from PyQt6 import QtGui
import numpy as np


Expand Down

0 comments on commit 3a967a5

Please sign in to comment.