From 4402da62ece15ecd20a481a0ec39903a392f37b6 Mon Sep 17 00:00:00 2001 From: Bastian Germann Date: Mon, 13 Apr 2026 21:30:06 +0200 Subject: [PATCH] Use GUI Qt bindings through pyqtgraph for PyQt5/PyQt6 support Replace direct PyQt5 imports with pyqtgraph.Qt compatibility imports across the app. Migrate signal/slot/property aliases and update exec_ calls to exec for Qt6 compatibility. Add runtime Qt binding detection (prefer PyQt6, fallback to PyQt5). Update QLibraryInfo translation path handling to support both Qt5 and Qt6 APIs. Rework Qt/WebEngine helper modules and tab shortcut handling for cross-version behavior. --- KuttyPyAndroidQuiz.py | 24 ++++++------ KuttyPyGUI.py | 26 ++++++------- KuttyPyIDE.py | 44 +++++++++++----------- KuttyPyNano.py | 20 +++++----- KuttyPyPlus.py | 34 ++++++++--------- KuttyPyQuizSocketio.py | 26 ++++++------- KuttyPyUno.py | 20 +++++----- KuttyPyVisual.py | 30 +++++++-------- Makefile | 4 ++ __init__.py | 4 +- online/blockly_mp_routes.py | 2 +- online/blockly_routes.py | 2 +- online/compile_routes.py | 2 +- online/compile_server.py | 8 ++-- online/mp.py | 12 +++--- utilities/MyTabBrowser.py | 13 +++---- utilities/Qt.py | 41 ++++++++++---------- utilities/__init__.py | 4 +- utilities/dio.py | 4 +- utilities/ipy.py | 2 +- utilities/pipinstaller.py | 4 +- utilities/quiz_server.py | 6 +-- utilities/quiz_server_backup.py | 6 +-- utilities/quiz_server_socketio.py | 10 ++--- utilities/syntax.py | 2 +- utilities/templates/Makefile | 13 ++++++- utilities/templates/gauge.py | 4 +- utilities/templates/nano_rc.py | 2 +- utilities/templates/promoted.py | 2 +- utilities/templates/res_rc.py | 2 +- utilities/templates/resplus_rc.py | 2 +- utilities/templates/ui_blockly_layout.py | 2 +- utilities/templates/ui_category_row_2.py | 2 +- utilities/templates/ui_dio.py | 2 +- utilities/templates/ui_dio_adc.py | 2 +- utilities/templates/ui_dio_adcConfig.py | 2 +- utilities/templates/ui_dio_adcLog.py | 2 +- utilities/templates/ui_dio_cntr.py | 2 +- utilities/templates/ui_dio_control.py | 2 +- utilities/templates/ui_dio_motor_shield.py | 2 +- utilities/templates/ui_dio_pwm.py | 2 +- utilities/templates/ui_dio_robot.py | 2 +- utilities/templates/ui_dio_sensor.py | 2 +- utilities/templates/ui_dio_stepper.py | 2 +- utilities/templates/ui_dummyio.py | 2 +- utilities/templates/ui_expt_row.py | 2 +- utilities/templates/ui_ipy.py | 2 +- utilities/templates/ui_layout.py | 2 +- utilities/templates/ui_layout_ide.py | 2 +- utilities/templates/ui_layout_quiz.py | 2 +- utilities/templates/ui_layout_visual.py | 2 +- utilities/templates/ui_layoutnano.py | 2 +- utilities/templates/ui_layoutplus.py | 2 +- utilities/templates/ui_layoutuno.py | 2 +- utilities/templates/ui_quiz_row.py | 2 +- utilities/templates/ui_regedit.py | 2 +- utilities/templates/ui_regvals.py | 2 +- utilities/templates/uno_rc.py | 2 +- utilities/texteditor.py | 2 +- utilities/vissyntax.py | 2 +- utilities/webBrowser.py | 33 ++++++++++------ utilities/widgetUtils.py | 10 ++--- 62 files changed, 249 insertions(+), 227 deletions(-) diff --git a/KuttyPyAndroidQuiz.py b/KuttyPyAndroidQuiz.py index d38c0e7..c7bac8a 100644 --- a/KuttyPyAndroidQuiz.py +++ b/KuttyPyAndroidQuiz.py @@ -8,7 +8,7 @@ import sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) -from PyQt5 import QtGui, QtCore, QtWidgets +from pyqtgraph.Qt import QtGui, QtCore, QtWidgets from utilities import syntax from utilities import texteditor @@ -54,13 +54,13 @@ def getscr(self): class AppWindow(QtWidgets.QMainWindow, layout.Ui_MainWindow): p = None - logThis = QtCore.pyqtSignal(str) - showStatusSignal = QtCore.pyqtSignal(str, bool) - serverSignal = QtCore.pyqtSignal(str,str) - removeSignal = QtCore.pyqtSignal(str) - imageSignal = QtCore.pyqtSignal(str,bytes) - logThisPlain = QtCore.pyqtSignal(bytes) - codeOutput = QtCore.pyqtSignal(str, str) + logThis = QtCore.Signal(str) + showStatusSignal = QtCore.Signal(str, bool) + serverSignal = QtCore.Signal(str,str) + removeSignal = QtCore.Signal(str) + imageSignal = QtCore.Signal(str,bytes) + logThisPlain = QtCore.Signal(bytes) + codeOutput = QtCore.Signal(str, str) def __init__(self, parent=None, **kwargs): super(AppWindow, self).__init__(parent) @@ -217,7 +217,7 @@ def registerScreenshot(self, addr, msg): image.loadFromData(QtCore.QByteArray(msg)) # Create and show the ImageDialog dialog = ImageDialog(image) - dialog.exec_() + dialog.exec() def activateQuizListener(self): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) @@ -562,7 +562,7 @@ def showStatus(self, msg, error=None): ######## WINDOW EXPORT SVG def exportSvg(self): - from PyQt5 import QtSvg + from pyqtgraph.Qt import QtSvg path, _filter = QtWidgets.QFileDialog.getSaveFileName(self, 'Save File', '~/') if path: generator = QtSvg.QSvgGenerator() @@ -590,7 +590,7 @@ def translators(langDir, lang=None): result = [] qtTranslator = QtCore.QTranslator() qtTranslator.load("qt_" + lang, - QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) + (QtCore.QLibraryInfo.path if hasattr(QtCore.QLibraryInfo, 'path') else QtCore.QLibraryInfo.location)(QtCore.QLibraryInfo.TranslationsPath)) result.append(qtTranslator) # path to the translation files (.qm files) @@ -662,7 +662,7 @@ def run(): myapp = AppWindow(app=app, path=path) myapp.show() - r = app.exec_() + r = app.exec() ''' if myapp.compile_thread is not None: myapp.compile_thread.terminate() diff --git a/KuttyPyGUI.py b/KuttyPyGUI.py index c74a935..9578379 100755 --- a/KuttyPyGUI.py +++ b/KuttyPyGUI.py @@ -5,7 +5,7 @@ import os,sys,time,re,traceback,platform sys.path.append(os.path.dirname(os.path.abspath(__file__))) -from PyQt5 import QtGui, QtCore, QtWidgets +from pyqtgraph.Qt import QtGui, QtCore, QtWidgets import KuttyPyLib from utilities.templates import ui_layout as layout @@ -29,7 +29,7 @@ def translate(lang = None): app.installTranslator(t) t1=QtCore.QTranslator() t1.load("qt_"+lang, - QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) + (QtCore.QLibraryInfo.path if hasattr(QtCore.QLibraryInfo, 'path') else QtCore.QLibraryInfo.location)(QtCore.QLibraryInfo.TranslationsPath)) app.installTranslator(t1) @@ -54,9 +54,9 @@ def progress(self): class AppWindow(QtWidgets.QMainWindow, layout.Ui_MainWindow): p=None ports = ['A','B','C','D'] - logThis = QtCore.pyqtSignal(str) - logThisPlain = QtCore.pyqtSignal(bytes) - serialGaugeSignal = QtCore.pyqtSignal(bytes) + logThis = QtCore.Signal(str) + logThisPlain = QtCore.Signal(bytes) + serialGaugeSignal = QtCore.Signal(bytes) serialGaugeConvert = 'bytes' serialStream = b'' def __init__(self, parent=None,**kwargs): @@ -218,8 +218,8 @@ def setLogType(self,tp): ################USER CODE SECTION#################### class codeObject(QtCore.QObject): - finished = QtCore.pyqtSignal() - logThis = QtCore.pyqtSignal(str) + finished = QtCore.Signal() + logThis = QtCore.Signal(str) code = '' def __init__(self,REGISTERS): @@ -550,9 +550,9 @@ def loadExample(self,filename): ########################### UPLOAD HEX FILE ####################### class uploadObject(QtCore.QObject): - finished = QtCore.pyqtSignal() - logThis = QtCore.pyqtSignal(str) - logThisPlain = QtCore.pyqtSignal(bytes) + finished = QtCore.Signal() + logThis = QtCore.Signal(str) + logThisPlain = QtCore.Signal(bytes) fname = '' p = None def __init__(self): @@ -854,7 +854,7 @@ def updateStatus(self): ######## WINDOW EXPORT SVG def exportSvg(self): - from PyQt5 import QtSvg + from pyqtgraph.Qt import QtSvg path, _filter = QtWidgets.QFileDialog.getSaveFileName(self, 'Save File', '~/') if path: generator = QtSvg.QSvgGenerator() @@ -890,7 +890,7 @@ def translators(langDir, lang=None): result=[] qtTranslator=QtCore.QTranslator() qtTranslator.load("qt_" + lang, - QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) + (QtCore.QLibraryInfo.path if hasattr(QtCore.QLibraryInfo, 'path') else QtCore.QLibraryInfo.location)(QtCore.QLibraryInfo.TranslationsPath)) result.append(qtTranslator) # path to the translation files (.qm files) @@ -954,7 +954,7 @@ def run(): app = QtWidgets.QApplication(sys.argv) myapp = AppWindow(app=app, path=path) myapp.show() - r = app.exec_() + r = app.exec() ''' if myapp.p.connected: myapp.p.fd.write(b'j') diff --git a/KuttyPyIDE.py b/KuttyPyIDE.py index adebaa9..c5aefb6 100644 --- a/KuttyPyIDE.py +++ b/KuttyPyIDE.py @@ -5,9 +5,9 @@ import os, sys, time, re, traceback, platform from typing import List -from PyQt5 import QtGui, QtCore, QtWidgets -from PyQt5.QtCore import QThread -from PyQt5.QtGui import QPixmap +from pyqtgraph.Qt import QtGui, QtCore, QtWidgets +from pyqtgraph.Qt.QtCore import QThread +from pyqtgraph.Qt.QtGui import QPixmap sys.path.append(os.path.dirname(os.path.abspath(__file__))) @@ -34,7 +34,7 @@ def translate(lang=None): app.installTranslator(t) t1 = QtCore.QTranslator() t1.load("qt_" + lang, - QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) + (QtCore.QLibraryInfo.path if hasattr(QtCore.QLibraryInfo, 'path') else QtCore.QLibraryInfo.location)(QtCore.QLibraryInfo.TranslationsPath)) app.installTranslator(t1) @@ -66,17 +66,17 @@ def progress(self): class AppWindow(QtWidgets.QMainWindow, layout.Ui_MainWindow): p = None - logThis = QtCore.pyqtSignal(str) - showStatusSignal = QtCore.pyqtSignal(str, bool) - serverSignal = QtCore.pyqtSignal(str) - addMPSignal = QtCore.pyqtSignal() - delMPSignal = QtCore.pyqtSignal() - queryMPSignal = QtCore.pyqtSignal() - cameraReadySignal = QtCore.pyqtSignal() - - logThisPlain = QtCore.pyqtSignal(bytes) - codeOutput = QtCore.pyqtSignal(str, str) - serialGaugeSignal = QtCore.pyqtSignal(bytes) + logThis = QtCore.Signal(str) + showStatusSignal = QtCore.Signal(str, bool) + serverSignal = QtCore.Signal(str) + addMPSignal = QtCore.Signal() + delMPSignal = QtCore.Signal() + queryMPSignal = QtCore.Signal() + cameraReadySignal = QtCore.Signal() + + logThisPlain = QtCore.Signal(bytes) + codeOutput = QtCore.Signal(str, str) + serialGaugeSignal = QtCore.Signal(bytes) serialGaugeConvert = 'bytes' serialStream = b'' @@ -753,10 +753,10 @@ def updateEverything(self): ########################### UPLOAD HEX FILE ####################### class uploadObject(QtCore.QObject): - finished = QtCore.pyqtSignal() - logThis = QtCore.pyqtSignal(str) - resultSignal = QtCore.pyqtSignal(str, str) - logThisPlain = QtCore.pyqtSignal(bytes) + finished = QtCore.Signal() + logThis = QtCore.Signal(str) + resultSignal = QtCore.Signal(str, str) + logThisPlain = QtCore.Signal(bytes) fname = '' p = None @@ -1176,7 +1176,7 @@ def checkConnectionStatus(self, dialog=False): ######## WINDOW EXPORT SVG def exportSvg(self): - from PyQt5 import QtSvg + from pyqtgraph.Qt import QtSvg path, _filter = QtWidgets.QFileDialog.getSaveFileName(self, 'Save File', '~/') if path: generator = QtSvg.QSvgGenerator() @@ -1204,7 +1204,7 @@ def translators(langDir, lang=None): result = [] qtTranslator = QtCore.QTranslator() qtTranslator.load("qt_" + lang, - QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) + (QtCore.QLibraryInfo.path if hasattr(QtCore.QLibraryInfo, 'path') else QtCore.QLibraryInfo.location)(QtCore.QLibraryInfo.TranslationsPath)) result.append(qtTranslator) # path to the translation files (.qm files) @@ -1279,7 +1279,7 @@ def run(): app = QtWidgets.QApplication(sys.argv) myapp = AppWindow(app=app, path=path) myapp.show() - r = app.exec_() + r = app.exec() if myapp.mp_thread is not None: myapp.mp_thread.stopRunning() diff --git a/KuttyPyNano.py b/KuttyPyNano.py index e373b74..da4f3b4 100644 --- a/KuttyPyNano.py +++ b/KuttyPyNano.py @@ -40,9 +40,9 @@ def progress(self): class AppWindow(QtWidgets.QMainWindow, layout.Ui_MainWindow): p=None - logThis = QtCore.pyqtSignal(str) - logThisPlain = QtCore.pyqtSignal(bytes) - serialGaugeSignal = QtCore.pyqtSignal(int) + logThis = QtCore.Signal(str) + logThisPlain = QtCore.Signal(bytes) + serialGaugeSignal = QtCore.Signal(int) def __init__(self, parent=None,**kwargs): super(AppWindow, self).__init__(parent) self.setupUi(self) @@ -169,8 +169,8 @@ def tabChanged(self,index): ################USER CODE SECTION#################### class codeObject(QtCore.QObject): - finished = QtCore.pyqtSignal() - logThis = QtCore.pyqtSignal(str) + finished = QtCore.Signal() + logThis = QtCore.Signal(str) code = '' def __init__(self,REGISTERS): @@ -489,9 +489,9 @@ def loadExample(self,filename): ########################### UPLOAD HEX FILE ####################### class uploadObject(QtCore.QObject): - finished = QtCore.pyqtSignal() - logThis = QtCore.pyqtSignal(str) - logThisPlain = QtCore.pyqtSignal(bytes) + finished = QtCore.Signal() + logThis = QtCore.Signal(str) + logThisPlain = QtCore.Signal(bytes) fname = '' p = None def __init__(self): @@ -760,7 +760,7 @@ def translators(langDir, lang=None): result=[] qtTranslator=QtCore.QTranslator() qtTranslator.load("qt_" + lang, - QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) + (QtCore.QLibraryInfo.path if hasattr(QtCore.QLibraryInfo, 'path') else QtCore.QLibraryInfo.location)(QtCore.QLibraryInfo.TranslationsPath)) result.append(qtTranslator) # path to the translation files (.qm files) @@ -825,7 +825,7 @@ def run(): myapp = AppWindow(app=app, path=path) myapp.show() - r = app.exec_() + r = app.exec() ''' if myapp.p.connected: myapp.p.fd.write(b'j') diff --git a/KuttyPyPlus.py b/KuttyPyPlus.py index f2e5804..dd2e3d2 100644 --- a/KuttyPyPlus.py +++ b/KuttyPyPlus.py @@ -6,7 +6,7 @@ sys.path.append(os.path.dirname(os.path.abspath(__file__))) -from PyQt5 import QtGui, QtCore, QtWidgets +from pyqtgraph.Qt import QtGui, QtCore, QtWidgets import KuttyPyLib import socket @@ -30,7 +30,7 @@ def translate(lang=None): app.installTranslator(t) t1 = QtCore.QTranslator() t1.load("qt_" + lang, - QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) + (QtCore.QLibraryInfo.path if hasattr(QtCore.QLibraryInfo, 'path') else QtCore.QLibraryInfo.location)(QtCore.QLibraryInfo.TranslationsPath)) app.installTranslator(t1) @@ -59,12 +59,12 @@ def progress(self): class AppWindow(QtWidgets.QMainWindow, layout.Ui_MainWindow): p = None ports = ['A', 'B', 'C', 'D'] - logThis = QtCore.pyqtSignal(str) - showStatusSignal = QtCore.pyqtSignal(str, bool) - serverSignal = QtCore.pyqtSignal(str) - logThisPlain = QtCore.pyqtSignal(bytes) - codeOutput = QtCore.pyqtSignal(str, str) - serialGaugeSignal = QtCore.pyqtSignal(bytes) + logThis = QtCore.Signal(str) + showStatusSignal = QtCore.Signal(str, bool) + serverSignal = QtCore.Signal(str) + logThisPlain = QtCore.Signal(bytes) + codeOutput = QtCore.Signal(str, str) + serialGaugeSignal = QtCore.Signal(bytes) serialGaugeConvert = 'bytes' serialStream = b'' @@ -436,8 +436,8 @@ def openHexTab(self): self.codingTabs.addTab(self.hexTab, "") class codeObject(QtCore.QObject): - finished = QtCore.pyqtSignal() - logThis = QtCore.pyqtSignal(str) + finished = QtCore.Signal() + logThis = QtCore.Signal(str) code = '' def __init__(self, REGISTERS): @@ -781,10 +781,10 @@ def loadExample(self, filename): ########################### UPLOAD HEX FILE ####################### class uploadObject(QtCore.QObject): - finished = QtCore.pyqtSignal() - logThis = QtCore.pyqtSignal(str) - resultSignal = QtCore.pyqtSignal(str, str) - logThisPlain = QtCore.pyqtSignal(bytes) + finished = QtCore.Signal() + logThis = QtCore.Signal(str) + resultSignal = QtCore.Signal(str, str) + logThisPlain = QtCore.Signal(bytes) fname = '' p = None @@ -1177,7 +1177,7 @@ def checkConnectionStatus(self, dialog=False): ######## WINDOW EXPORT SVG def exportSvg(self): - from PyQt5 import QtSvg + from pyqtgraph.Qt import QtSvg path, _filter = QtWidgets.QFileDialog.getSaveFileName(self, 'Save File', '~/') if path: generator = QtSvg.QSvgGenerator() @@ -1214,7 +1214,7 @@ def translators(langDir, lang=None): result = [] qtTranslator = QtCore.QTranslator() qtTranslator.load("qt_" + lang, - QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) + (QtCore.QLibraryInfo.path if hasattr(QtCore.QLibraryInfo, 'path') else QtCore.QLibraryInfo.location)(QtCore.QLibraryInfo.TranslationsPath)) result.append(qtTranslator) # path to the translation files (.qm files) @@ -1323,7 +1323,7 @@ def run(): print('QT Version', QtWidgets.__file__) myapp = AppWindow(app=app, path=path, splash= splash) myapp.show() - r = app.exec_() + r = app.exec() if myapp.compile_thread is not None: myapp.compile_thread.terminate() print('waiting to quit compile_thread') diff --git a/KuttyPyQuizSocketio.py b/KuttyPyQuizSocketio.py index f416c2b..bbed363 100644 --- a/KuttyPyQuizSocketio.py +++ b/KuttyPyQuizSocketio.py @@ -7,7 +7,7 @@ import socket import sys -from PyQt5 import QtGui, QtCore, QtWidgets +from pyqtgraph.Qt import QtGui, QtCore, QtWidgets from utilities import syntax from utilities import texteditor @@ -63,14 +63,14 @@ def getscr(self): class AppWindow(QtWidgets.QMainWindow, layout.Ui_MainWindow): p = None - logThis = QtCore.pyqtSignal(str) - showStatusSignal = QtCore.pyqtSignal(str, bool) - serverSignal = QtCore.pyqtSignal(str,str) - removeSignal = QtCore.pyqtSignal(str) - imageSignal = QtCore.pyqtSignal(str,bytes) - memSig = QtCore.pyqtSignal(list) - logThisPlain = QtCore.pyqtSignal(bytes) - codeOutput = QtCore.pyqtSignal(str, str) + logThis = QtCore.Signal(str) + showStatusSignal = QtCore.Signal(str, bool) + serverSignal = QtCore.Signal(str,str) + removeSignal = QtCore.Signal(str) + imageSignal = QtCore.Signal(str,bytes) + memSig = QtCore.Signal(list) + logThisPlain = QtCore.Signal(bytes) + codeOutput = QtCore.Signal(str, str) def __init__(self, parent=None, **kwargs): super(AppWindow, self).__init__(parent) @@ -232,7 +232,7 @@ def registerScreenshot(self, addr, msg): image.loadFromData(QtCore.QByteArray(msg)) # Create and show the ImageDialog dialog = ImageDialog(image) - dialog.exec_() + dialog.exec() def addFileMenu(self): codeMenu = QtWidgets.QMenu() @@ -548,7 +548,7 @@ def showStatus(self, msg, error=None): ######## WINDOW EXPORT SVG def exportSvg(self): - from PyQt5 import QtSvg + from pyqtgraph.Qt import QtSvg path, _filter = QtWidgets.QFileDialog.getSaveFileName(self, 'Save File', '~/') if path: generator = QtSvg.QSvgGenerator() @@ -586,7 +586,7 @@ def translators(langDir, lang=None): result = [] qtTranslator = QtCore.QTranslator() qtTranslator.load("qt_" + lang, - QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) + (QtCore.QLibraryInfo.path if hasattr(QtCore.QLibraryInfo, 'path') else QtCore.QLibraryInfo.location)(QtCore.QLibraryInfo.TranslationsPath)) result.append(qtTranslator) # path to the translation files (.qm files) @@ -656,7 +656,7 @@ def run(): app = QtWidgets.QApplication(sys.argv) myapp = AppWindow(app=app, path=path) myapp.show() - r = app.exec_() + r = app.exec() ''' if myapp.compile_thread is not None: myapp.compile_thread.terminate() diff --git a/KuttyPyUno.py b/KuttyPyUno.py index 084632d..89e0b7b 100644 --- a/KuttyPyUno.py +++ b/KuttyPyUno.py @@ -38,9 +38,9 @@ def progress(self): class AppWindow(QtWidgets.QMainWindow, layout.Ui_MainWindow): p=None - logThis = QtCore.pyqtSignal(str) - logThisPlain = QtCore.pyqtSignal(bytes) - serialGaugeSignal = QtCore.pyqtSignal(int) + logThis = QtCore.Signal(str) + logThisPlain = QtCore.Signal(bytes) + serialGaugeSignal = QtCore.Signal(int) def __init__(self, parent=None,**kwargs): super(AppWindow, self).__init__(parent) self.setupUi(self) @@ -184,8 +184,8 @@ def tabChanged(self,index): ################USER CODE SECTION#################### class codeObject(QtCore.QObject): - finished = QtCore.pyqtSignal() - logThis = QtCore.pyqtSignal(str) + finished = QtCore.Signal() + logThis = QtCore.Signal(str) code = '' def __init__(self,REGISTERS): @@ -504,9 +504,9 @@ def loadExample(self,filename): ########################### UPLOAD HEX FILE ####################### class uploadObject(QtCore.QObject): - finished = QtCore.pyqtSignal() - logThis = QtCore.pyqtSignal(str) - logThisPlain = QtCore.pyqtSignal(bytes) + finished = QtCore.Signal() + logThis = QtCore.Signal(str) + logThisPlain = QtCore.Signal(bytes) fname = '' p = None def __init__(self): @@ -775,7 +775,7 @@ def translators(langDir, lang=None): result=[] qtTranslator=QtCore.QTranslator() qtTranslator.load("qt_" + lang, - QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)) + (QtCore.QLibraryInfo.path if hasattr(QtCore.QLibraryInfo, 'path') else QtCore.QLibraryInfo.location)(QtCore.QLibraryInfo.TranslationsPath)) result.append(qtTranslator) # path to the translation files (.qm files) @@ -840,7 +840,7 @@ def run(): myapp = AppWindow(app=app, path=path) myapp.show() - r = app.exec_() + r = app.exec() ''' if myapp.p.connected: myapp.p.fd.write(b'j') diff --git a/KuttyPyVisual.py b/KuttyPyVisual.py index 802934c..dd1961a 100644 --- a/KuttyPyVisual.py +++ b/KuttyPyVisual.py @@ -5,9 +5,9 @@ import os, sys, time, re, traceback, platform from typing import List -from PyQt5 import QtGui, QtCore, QtWidgets -from PyQt5.QtCore import QThread -from PyQt5.QtGui import QPixmap +from pyqtgraph.Qt import QtGui, QtCore, QtWidgets +from pyqtgraph.Qt.QtCore import QThread +from pyqtgraph.Qt.QtGui import QPixmap sys.path.append(os.path.dirname(os.path.abspath(__file__))) @@ -23,17 +23,17 @@ class AppWindow(QtWidgets.QMainWindow, layout.Ui_MainWindow): p = None - logThis = QtCore.pyqtSignal(str) - showStatusSignal = QtCore.pyqtSignal(str, bool) - serverSignal = QtCore.pyqtSignal(str) - addMPSignal = QtCore.pyqtSignal() - delMPSignal = QtCore.pyqtSignal() - queryMPSignal = QtCore.pyqtSignal() - cameraReadySignal = QtCore.pyqtSignal() - - logThisPlain = QtCore.pyqtSignal(bytes) - codeOutput = QtCore.pyqtSignal(str, str) - serialGaugeSignal = QtCore.pyqtSignal(bytes) + logThis = QtCore.Signal(str) + showStatusSignal = QtCore.Signal(str, bool) + serverSignal = QtCore.Signal(str) + addMPSignal = QtCore.Signal() + delMPSignal = QtCore.Signal() + queryMPSignal = QtCore.Signal() + cameraReadySignal = QtCore.Signal() + + logThisPlain = QtCore.Signal(bytes) + codeOutput = QtCore.Signal(str, str) + serialGaugeSignal = QtCore.Signal(bytes) serialGaugeConvert = 'bytes' serialStream = b'' @@ -357,7 +357,7 @@ def run(): app = QtWidgets.QApplication(sys.argv) myapp = AppWindow(app=app, path=path) myapp.show() - r = app.exec_() + r = app.exec() if myapp.mp_thread is not None: myapp.mp_thread.stopRunning() diff --git a/Makefile b/Makefile index 0a83bb6..f64eeaa 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,10 @@ ifeq ($(QT_VERSION),PyQt5) PYUIC = pyuic5 PYRCC = pyrcc5 PYLUPDATE = pylupdate5 +else ifeq ($(QT_VERSION),PyQt6) + PYUIC = pyuic6 + PYRCC = rcc -g python + PYLUPDATE = pylupdate6 else ifeq ($(QT_VERSION),PyQt4) PYUIC = pyuic4 PYRCC = pyrcc4 diff --git a/__init__.py b/__init__.py index e98d52a..858e1e9 100644 --- a/__init__.py +++ b/__init__.py @@ -1,7 +1,7 @@ # seelab_examples/__init__.py import sys,os, json, time -from PyQt5 import QtWidgets, QtGui, QtCore +from pyqtgraph.Qt import QtWidgets, QtGui, QtCore import argparse # Added import for argparse from .KuttyPyPlus import run # Adjust the import based on your actual script structure @@ -79,5 +79,5 @@ def main(): window = run() window.show() - sys.exit(app.exec_()) + sys.exit(app.exec()) diff --git a/online/blockly_mp_routes.py b/online/blockly_mp_routes.py index ef5b3e2..b1e5214 100644 --- a/online/blockly_mp_routes.py +++ b/online/blockly_mp_routes.py @@ -2,7 +2,7 @@ from flask import Blueprint, render_template, request, session, send_from_directory, current_app, jsonify import os, tempfile, subprocess, json, glob -from PyQt5 import QtCore +from pyqtgraph.Qt import QtCore from online.mp import HandTrackingDialog diff --git a/online/blockly_routes.py b/online/blockly_routes.py index bb803c7..7e0d01a 100644 --- a/online/blockly_routes.py +++ b/online/blockly_routes.py @@ -1,6 +1,6 @@ from flask import Blueprint, render_template, request, session, send_from_directory, current_app, jsonify import os, tempfile, subprocess, json, glob -from PyQt5 import QtCore +from pyqtgraph.Qt import QtCore bly = Blueprint('blockly', __name__) diff --git a/online/compile_routes.py b/online/compile_routes.py index de3fbe8..1bacf0c 100644 --- a/online/compile_routes.py +++ b/online/compile_routes.py @@ -1,6 +1,6 @@ from flask import Blueprint, render_template, request, session, send_from_directory, current_app import os, tempfile, subprocess, json, glob -from PyQt5 import QtCore +from pyqtgraph.Qt import QtCore main = Blueprint('main', __name__) diff --git a/online/compile_server.py b/online/compile_server.py index 0f233c5..56c74ff 100644 --- a/online/compile_server.py +++ b/online/compile_server.py @@ -4,8 +4,8 @@ from flask import Flask, request, Blueprint, jsonify import logging from flask_cors import CORS -from PyQt5.QtCore import QThread, pyqtSignal, QObject, QEventLoop -from PyQt5.QtWidgets import QApplication +from pyqtgraph.Qt.QtCore import QThread, Signal, QObject, QEventLoop +from pyqtgraph.Qt.QtWidgets import QApplication # blueprint for socket comms parts of app from .compile_routes import main as main_blueprint, local_ip @@ -49,7 +49,7 @@ def log(self, type, message, *args): pass # Disable the logging class FlaskThread(QThread): - finished = pyqtSignal() + finished = Signal() serverSignal = None MPSlots= None @@ -140,7 +140,7 @@ def on_camera_ready(): self.cameraReadySignal.connect(on_camera_ready) self.addMPSignal.emit() print('connected camera ready signal...waiting..') - loop.exec_() + loop.exec() print('camera is ready. responding.') return jsonify({'response': 'ready'}) diff --git a/online/mp.py b/online/mp.py index fcfc746..c21a368 100644 --- a/online/mp.py +++ b/online/mp.py @@ -2,9 +2,9 @@ import cv2 import mediapipe as mp -from PyQt5.QtCore import QThread, pyqtSignal -from PyQt5.QtWidgets import QApplication, QLabel, QDialog, QVBoxLayout -from PyQt5.QtGui import QImage, QPixmap +from pyqtgraph.Qt.QtCore import QThread, Signal +from pyqtgraph.Qt.QtWidgets import QApplication, QLabel, QDialog, QVBoxLayout +from pyqtgraph.Qt.QtGui import QImage, QPixmap import sys,time # Initialize MediaPipe @@ -14,10 +14,10 @@ class HandLandmarkThread(QThread): - change_pixmap_signal = pyqtSignal(QImage) - coordinates_signal = pyqtSignal(list) # Signal to emit coordinates + change_pixmap_signal = Signal(QImage) + coordinates_signal = Signal(list) # Signal to emit coordinates cameraReadySignal = None - dead_signal = pyqtSignal() # Signal to emit coordinates + dead_signal = Signal() # Signal to emit coordinates running = True last_query_time = time.time() diff --git a/utilities/MyTabBrowser.py b/utilities/MyTabBrowser.py index a50effb..c870fa4 100644 --- a/utilities/MyTabBrowser.py +++ b/utilities/MyTabBrowser.py @@ -1,15 +1,14 @@ -from PyQt5.QtGui import QKeySequence -from PyQt5.QtWidgets import QTabWidget, QShortcut - -from utilities import Qt +from pyqtgraph.Qt.QtGui import QKeySequence +from pyqtgraph.Qt.QtWidgets import QTabWidget, QShortcut +from pyqtgraph.Qt import QtCore class MyTabBrowser(QTabWidget): def __init__(self): super().__init__() # Set up shortcuts for Ctrl+Left and Ctrl+Right - self.prev_tab_shortcut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Left), self) - self.next_tab_shortcut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Right), self) + self.prev_tab_shortcut = QShortcut(QKeySequence("Ctrl+Left"), self) + self.next_tab_shortcut = QShortcut(QKeySequence("Ctrl+Right"), self) # Connect shortcuts to navigation functions self.prev_tab_shortcut.activated.connect(self.showPreviousTab) @@ -17,7 +16,7 @@ def __init__(self): def keyPressEvent(self, event): # Override the keyPressEvent to prevent default handling of Ctrl+Tab - if event.key() == Qt.Key_Tab and event.modifiers() == Qt.ControlModifier: + if event.key() == QtCore.Qt.Key_Tab and event.modifiers() == QtCore.Qt.ControlModifier: return # Call the base class implementation for other key events diff --git a/utilities/Qt.py b/utilities/Qt.py index b98c98e..c450bb5 100644 --- a/utilities/Qt.py +++ b/utilities/Qt.py @@ -1,25 +1,22 @@ -## 'Qt' is a local module; it is intended mainly to cover up the differences -## between PyQt4 and PyQt5. +## 'Qt' is a local module; it covers differences between PyQt5 and PyQt6 +## by routing all Qt imports through pyqtgraph's compatibility layer. import os -ENVIRON = os.environ['CSMCA_QT_LIB'] +ENVIRON = os.environ.get('CSMCA_QT_LIB', 'PyQt5') -if ENVIRON=='PyQt5': - print('PyQt5 imported') - from PyQt5 import QtGui,QtCore,QtWidgets - try: from PyQt5 import QtSvg - except: pass - try: - #from PyQt5.QtWebEngineWidgets import QWebEngineView as QWebView - from PyQt5.QtWebKitWidgets import QWebView# , QWebPage - except: - QWebView = None -elif ENVIRON == 'PyQt4': - print('PyQt4 imported') - from PyQt4 import QtGui,QtCore - from PyQt4 import QtGui as QtWidgets - #try: - # from PyQt4.QtWebKitWidgets import QWebView# , QWebPage - #except: - # print('webview unavailable') - +from pyqtgraph.Qt import QtGui, QtCore, QtWidgets + +try: + from pyqtgraph.Qt import QtSvg +except ImportError: + pass + +# QtWebEngineWidgets is not wrapped by pyqtgraph; try each binding directly. +QWebView = None +try: + if ENVIRON == 'PyQt6': + from PyQt6.QtWebEngineWidgets import QWebEngineView as QWebView + else: + from PyQt5.QtWebEngineWidgets import QWebEngineView as QWebView +except ImportError: + QWebView = None diff --git a/utilities/__init__.py b/utilities/__init__.py index 37d581a..27290f2 100644 --- a/utilities/__init__.py +++ b/utilities/__init__.py @@ -2,8 +2,8 @@ from . import build_details ENVIRON = build_details.QT_VERSION -os.environ['PYQTGRAPH_QT_LIB'] = ENVIRON -os.environ['CSMCA_QT_LIB'] = ENVIRON +os.environ.setdefault('PYQTGRAPH_QT_LIB', ENVIRON) +os.environ.setdefault('CSMCA_QT_LIB', ENVIRON) #For remote operation #os.environ['DATABASE_URL'] = 'postgres:///eyes_db' diff --git a/utilities/dio.py b/utilities/dio.py index 53718ce..0d474ad 100644 --- a/utilities/dio.py +++ b/utilities/dio.py @@ -1,4 +1,4 @@ -from PyQt5 import QtGui,QtCore,QtWidgets +from pyqtgraph.Qt import QtGui,QtCore,QtWidgets from .templates import ui_dio,ui_dio_pwm,ui_dio_adc,ui_dio_adcLog,ui_dio_sensor,ui_regvals,ui_dio_cntr,ui_regedit,ui_dio_control from .templates import ui_dio_robot,ui_dio_stepper,ui_dummyio, ui_dio_motor_shield @@ -337,7 +337,7 @@ def __init__(self,name,Q,**kwargs): def config(self,evt): if not self.configWindow: self.configWindow = DIOADCCONFIG(self,'ADMUX',self.muxOptions.keys(),self.logstate,self.setConfig) - #self.configWindow.exec_() #Blocks UI (Modal), and only one instance can be shown + #self.configWindow.exec() #Blocks UI (Modal), and only one instance can be shown self.configWindow.show() # Non blocking. Multiple. def setConfig(self,val,log): diff --git a/utilities/ipy.py b/utilities/ipy.py index b80cfbf..8897d2b 100644 --- a/utilities/ipy.py +++ b/utilities/ipy.py @@ -123,6 +123,6 @@ def __del__(self): app = QtWidgets.QApplication(sys.argv) myapp = AppWindow(kp=None) myapp.show() - sys.exit(app.exec_()) + sys.exit(app.exec()) diff --git a/utilities/pipinstaller.py b/utilities/pipinstaller.py index 1a85259..0cc9f85 100644 --- a/utilities/pipinstaller.py +++ b/utilities/pipinstaller.py @@ -1,10 +1,10 @@ import platform import sys -from PyQt5.QtWidgets import ( +from pyqtgraph.Qt.QtWidgets import ( QApplication, QDialog, QVBoxLayout, QLabel, QLineEdit, QPushButton, QTextEdit, QProgressBar, QHBoxLayout ) -from PyQt5.QtCore import QProcess +from pyqtgraph.Qt.QtCore import QProcess class PipInstallDialog(QDialog): diff --git a/utilities/quiz_server.py b/utilities/quiz_server.py index 5be9c3e..25638fe 100644 --- a/utilities/quiz_server.py +++ b/utilities/quiz_server.py @@ -1,5 +1,5 @@ -from PyQt5.QtCore import QThread, pyqtSignal -from PyQt5.QtWidgets import QApplication +from pyqtgraph.Qt.QtCore import QThread, Signal +from pyqtgraph.Qt.QtWidgets import QApplication # blueprint for socket comms parts of app flask_thread = None @@ -28,7 +28,7 @@ def create_server(showStatusSignal, serverSignal, removeSignal, imageSignal, loc class QuizResponseThread(QThread): - finished = pyqtSignal() + finished = Signal() serverSignal = None removeSignal = None imageSignal = None diff --git a/utilities/quiz_server_backup.py b/utilities/quiz_server_backup.py index fe9ff4e..e75d549 100644 --- a/utilities/quiz_server_backup.py +++ b/utilities/quiz_server_backup.py @@ -1,5 +1,5 @@ -from PyQt5.QtCore import QThread, pyqtSignal -from PyQt5.QtWidgets import QApplication +from pyqtgraph.Qt.QtCore import QThread, Signal +from pyqtgraph.Qt.QtWidgets import QApplication # blueprint for socket comms parts of app flask_thread = None @@ -28,7 +28,7 @@ def create_server(showStatusSignal, serverSignal, removeSignal, imageSignal, loc class QuizResponseThread(QThread): - finished = pyqtSignal() + finished = Signal() serverSignal = None removeSignal = None imageSignal = None diff --git a/utilities/quiz_server_socketio.py b/utilities/quiz_server_socketio.py index ceb3113..d422934 100644 --- a/utilities/quiz_server_socketio.py +++ b/utilities/quiz_server_socketio.py @@ -1,6 +1,6 @@ -from PyQt5.QtCore import QThread, pyqtSignal +from pyqtgraph.Qt.QtCore import QThread, Signal import socketio, threading -from PyQt5.QtWidgets import QApplication +from pyqtgraph.Qt.QtWidgets import QApplication from aiohttp import web import asyncio @@ -11,9 +11,9 @@ connections = {} class SocketIOClient: - finished = pyqtSignal() - showStatusSignal = pyqtSignal() - memberSignal = pyqtSignal() + finished = Signal() + showStatusSignal = Signal() + memberSignal = Signal() serverSignal = None removeSignal = None imageSignal = None diff --git a/utilities/syntax.py b/utilities/syntax.py index acd088a..6f097d3 100644 --- a/utilities/syntax.py +++ b/utilities/syntax.py @@ -2,7 +2,7 @@ import sys -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets def format(color, style=''): diff --git a/utilities/templates/Makefile b/utilities/templates/Makefile index d9fb9ef..762081c 100644 --- a/utilities/templates/Makefile +++ b/utilities/templates/Makefile @@ -26,7 +26,18 @@ ui_%.py: %.ui $(PYUIC) --from-import $< -o $@ +# rcc -g python (Qt6) places -o before the input file and emits PySide6 imports; +# pyrcc5/pyrcc4 place the input before -o and emit PyQt5/PyQt4 imports. %_rc.py: %.qrc - $(PYRCC) $< -o $@ + if echo "$(PYRCC)" | grep -q "rcc -g"; then \ + $(PYRCC) -o $@ $<; \ + sed -i \ + -e 's/^from PySide6 import QtCore$$/from pyqtgraph.Qt import QtCore/' \ + -e 's/^import PySide6\.QtCore$$/from pyqtgraph.Qt import QtCore/' \ + -e 's/PySide6\.QtCore\./QtCore./g' \ + $@; \ + else \ + $(PYRCC) $< -o $@; \ + fi .PHONY: all clean diff --git a/utilities/templates/gauge.py b/utilities/templates/gauge.py index 30aeb16..28e9b46 100644 --- a/utilities/templates/gauge.py +++ b/utilities/templates/gauge.py @@ -12,7 +12,7 @@ import math import sys from ..Qt import QtGui, QtCore, QtWidgets -from PyQt5.QtGui import QColor +from pyqtgraph.Qt.QtGui import QColor @@ -122,7 +122,7 @@ def formattedFrequency(self): class Gauge(QtWidgets.QWidget): - valueChanged = QtCore.pyqtSignal(float) + valueChanged = QtCore.Signal(float) def __init__(self, parent=None, name=''): super(Gauge, self).__init__(parent) diff --git a/utilities/templates/nano_rc.py b/utilities/templates/nano_rc.py index c637839..a2ad4cb 100644 --- a/utilities/templates/nano_rc.py +++ b/utilities/templates/nano_rc.py @@ -6,7 +6,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt5 import QtCore +from pyqtgraph.Qt import QtCore qt_resource_data = b"\ \x00\x04\x4f\xee\ diff --git a/utilities/templates/promoted.py b/utilities/templates/promoted.py index abdc125..d542d25 100644 --- a/utilities/templates/promoted.py +++ b/utilities/templates/promoted.py @@ -1,7 +1,7 @@ from ..Qt import QtGui,QtCore,QtWidgets class Guage(QtWidgets.QWidget): - valueChanged = QtCore.pyqtSignal(float) + valueChanged = QtCore.Signal(float) def __init__(self, parent=None): super(Guage, self).__init__(parent) self.setWindowTitle("Analog Clock") diff --git a/utilities/templates/res_rc.py b/utilities/templates/res_rc.py index e2327c9..cee781a 100644 --- a/utilities/templates/res_rc.py +++ b/utilities/templates/res_rc.py @@ -6,7 +6,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt5 import QtCore +from pyqtgraph.Qt import QtCore qt_resource_data = b"\ \x00\x00\x08\x99\ diff --git a/utilities/templates/resplus_rc.py b/utilities/templates/resplus_rc.py index 3049ec3..0d8fb23 100644 --- a/utilities/templates/resplus_rc.py +++ b/utilities/templates/resplus_rc.py @@ -6,7 +6,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt5 import QtCore +from pyqtgraph.Qt import QtCore qt_resource_data = b"\ \x00\x00\x0a\x75\ diff --git a/utilities/templates/ui_blockly_layout.py b/utilities/templates/ui_blockly_layout.py index a38e204..2368cec 100644 --- a/utilities/templates/ui_blockly_layout.py +++ b/utilities/templates/ui_blockly_layout.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Form(object): diff --git a/utilities/templates/ui_category_row_2.py b/utilities/templates/ui_category_row_2.py index 273fbe7..73c2720 100644 --- a/utilities/templates/ui_category_row_2.py +++ b/utilities/templates/ui_category_row_2.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Form(object): diff --git a/utilities/templates/ui_dio.py b/utilities/templates/ui_dio.py index ef34b06..9e512a2 100644 --- a/utilities/templates/ui_dio.py +++ b/utilities/templates/ui_dio.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_stack(object): diff --git a/utilities/templates/ui_dio_adc.py b/utilities/templates/ui_dio_adc.py index ac44e5a..f9d3e3e 100644 --- a/utilities/templates/ui_dio_adc.py +++ b/utilities/templates/ui_dio_adc.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_stack(object): diff --git a/utilities/templates/ui_dio_adcConfig.py b/utilities/templates/ui_dio_adcConfig.py index bd3c3f2..a30b152 100644 --- a/utilities/templates/ui_dio_adcConfig.py +++ b/utilities/templates/ui_dio_adcConfig.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/utilities/templates/ui_dio_adcLog.py b/utilities/templates/ui_dio_adcLog.py index 6c395d7..307eb2d 100644 --- a/utilities/templates/ui_dio_adcLog.py +++ b/utilities/templates/ui_dio_adcLog.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/utilities/templates/ui_dio_cntr.py b/utilities/templates/ui_dio_cntr.py index 79d498a..866854f 100644 --- a/utilities/templates/ui_dio_cntr.py +++ b/utilities/templates/ui_dio_cntr.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Frame(object): diff --git a/utilities/templates/ui_dio_control.py b/utilities/templates/ui_dio_control.py index 5585c21..f97892b 100644 --- a/utilities/templates/ui_dio_control.py +++ b/utilities/templates/ui_dio_control.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/utilities/templates/ui_dio_motor_shield.py b/utilities/templates/ui_dio_motor_shield.py index 3adf39d..f44d04c 100644 --- a/utilities/templates/ui_dio_motor_shield.py +++ b/utilities/templates/ui_dio_motor_shield.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/utilities/templates/ui_dio_pwm.py b/utilities/templates/ui_dio_pwm.py index a75c12a..ebb6d3f 100644 --- a/utilities/templates/ui_dio_pwm.py +++ b/utilities/templates/ui_dio_pwm.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_stack(object): diff --git a/utilities/templates/ui_dio_robot.py b/utilities/templates/ui_dio_robot.py index 1c80c0c..af4a368 100644 --- a/utilities/templates/ui_dio_robot.py +++ b/utilities/templates/ui_dio_robot.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/utilities/templates/ui_dio_sensor.py b/utilities/templates/ui_dio_sensor.py index 13fc82b..1a90870 100644 --- a/utilities/templates/ui_dio_sensor.py +++ b/utilities/templates/ui_dio_sensor.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/utilities/templates/ui_dio_stepper.py b/utilities/templates/ui_dio_stepper.py index 6c6b17f..1553b41 100644 --- a/utilities/templates/ui_dio_stepper.py +++ b/utilities/templates/ui_dio_stepper.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/utilities/templates/ui_dummyio.py b/utilities/templates/ui_dummyio.py index 70b0b62..94ad4ca 100644 --- a/utilities/templates/ui_dummyio.py +++ b/utilities/templates/ui_dummyio.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Form(object): diff --git a/utilities/templates/ui_expt_row.py b/utilities/templates/ui_expt_row.py index 644d256..4284987 100644 --- a/utilities/templates/ui_expt_row.py +++ b/utilities/templates/ui_expt_row.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Form(object): diff --git a/utilities/templates/ui_ipy.py b/utilities/templates/ui_ipy.py index 146f328..f3d03d5 100644 --- a/utilities/templates/ui_ipy.py +++ b/utilities/templates/ui_ipy.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): diff --git a/utilities/templates/ui_layout.py b/utilities/templates/ui_layout.py index 4d46719..54e0fe1 100644 --- a/utilities/templates/ui_layout.py +++ b/utilities/templates/ui_layout.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): diff --git a/utilities/templates/ui_layout_ide.py b/utilities/templates/ui_layout_ide.py index e66189b..d052cb3 100644 --- a/utilities/templates/ui_layout_ide.py +++ b/utilities/templates/ui_layout_ide.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): diff --git a/utilities/templates/ui_layout_quiz.py b/utilities/templates/ui_layout_quiz.py index ed0f741..ec9f206 100644 --- a/utilities/templates/ui_layout_quiz.py +++ b/utilities/templates/ui_layout_quiz.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): diff --git a/utilities/templates/ui_layout_visual.py b/utilities/templates/ui_layout_visual.py index 9a4942f..375ba9d 100644 --- a/utilities/templates/ui_layout_visual.py +++ b/utilities/templates/ui_layout_visual.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): diff --git a/utilities/templates/ui_layoutnano.py b/utilities/templates/ui_layoutnano.py index 07f53e4..ee9ec30 100644 --- a/utilities/templates/ui_layoutnano.py +++ b/utilities/templates/ui_layoutnano.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): diff --git a/utilities/templates/ui_layoutplus.py b/utilities/templates/ui_layoutplus.py index e309add..3a8d087 100644 --- a/utilities/templates/ui_layoutplus.py +++ b/utilities/templates/ui_layoutplus.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): diff --git a/utilities/templates/ui_layoutuno.py b/utilities/templates/ui_layoutuno.py index ac01bbb..fa35e31 100644 --- a/utilities/templates/ui_layoutuno.py +++ b/utilities/templates/ui_layoutuno.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): diff --git a/utilities/templates/ui_quiz_row.py b/utilities/templates/ui_quiz_row.py index 30a0a4d..96a05f0 100644 --- a/utilities/templates/ui_quiz_row.py +++ b/utilities/templates/ui_quiz_row.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Form(object): diff --git a/utilities/templates/ui_regedit.py b/utilities/templates/ui_regedit.py index d854329..8e72a3a 100644 --- a/utilities/templates/ui_regedit.py +++ b/utilities/templates/ui_regedit.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Frame(object): diff --git a/utilities/templates/ui_regvals.py b/utilities/templates/ui_regvals.py index 1a4dcd8..3e38f5d 100644 --- a/utilities/templates/ui_regvals.py +++ b/utilities/templates/ui_regvals.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets class Ui_Frame(object): diff --git a/utilities/templates/uno_rc.py b/utilities/templates/uno_rc.py index c17d20c..4449381 100644 --- a/utilities/templates/uno_rc.py +++ b/utilities/templates/uno_rc.py @@ -6,7 +6,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt5 import QtCore +from pyqtgraph.Qt import QtCore qt_resource_data = b"\ \x00\x00\x08\x67\ diff --git a/utilities/texteditor.py b/utilities/texteditor.py index 6baaac3..0afdc8f 100644 --- a/utilities/texteditor.py +++ b/utilities/texteditor.py @@ -1,6 +1,6 @@ # Adapted from https://gist.github.com/LegoStormtroopr/6146161 -from PyQt5 import QtGui, QtCore, QtWidgets +from pyqtgraph.Qt import QtGui, QtCore, QtWidgets class myTextEditor(QtWidgets.QPlainTextEdit): diff --git a/utilities/vissyntax.py b/utilities/vissyntax.py index 02cde7c..571bf40 100644 --- a/utilities/vissyntax.py +++ b/utilities/vissyntax.py @@ -2,7 +2,7 @@ import sys -from PyQt5 import QtCore, QtGui, QtWidgets +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets def format(color, style=''): """Return a QTextCharFormat with the given attributes. diff --git a/utilities/webBrowser.py b/utilities/webBrowser.py index e6aa28e..a309165 100644 --- a/utilities/webBrowser.py +++ b/utilities/webBrowser.py @@ -1,23 +1,34 @@ # -*- coding: utf-8; mode: python; indent-tabs-mode: t; tab-width:4 -*- print('importing webbrowser') -import os,string,glob +import os, string, glob -from PyQt5 import QtGui,QtCore,QtWidgets -from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage -from PyQt5 import QtWebEngineWidgets +from pyqtgraph.Qt import QtGui, QtCore, QtWidgets +# QtWebEngineWidgets is not wrapped by pyqtgraph; try PyQt6 then PyQt5. +try: + from PyQt6.QtWebEngineWidgets import QWebEngineView + from PyQt6.QtWebEngineCore import QWebEnginePage + import PyQt6.QtWebEngineWidgets as QtWebEngineWidgets +except ImportError: + try: + from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage + import PyQt5.QtWebEngineWidgets as QtWebEngineWidgets + except ImportError: + QWebEngineView = None + QWebEnginePage = None + QtWebEngineWidgets = None +import sys, pkg_resources -import sys,pkg_resources -class codeBrowser(QWebView): - def __init__(self,*args,**kwargs): +class codeBrowser(QWebEngineView): + def __init__(self, *args, **kwargs): super(codeBrowser, self).__init__() self.code_path = '.' sys.path.append(self.code_path) self.showMaximized() - - def setFile(self,url): + + def setFile(self, url): newUrl = QtCore.QUrl.fromLocalFile(QtCore.QFileInfo(url).absoluteFilePath()) - print ('SETTING URL',url,newUrl) - self.setUrl(newUrl)#pkg_resources.resource_filename('eyes_html',url))) + print('SETTING URL', url, newUrl) + self.setUrl(newUrl) diff --git a/utilities/widgetUtils.py b/utilities/widgetUtils.py index 143a39f..5e75c4d 100644 --- a/utilities/widgetUtils.py +++ b/utilities/widgetUtils.py @@ -3,12 +3,12 @@ import time from functools import partial -from PyQt5 import QtGui, QtCore, QtWidgets +from pyqtgraph.Qt import QtGui, QtCore, QtWidgets import pyqtgraph as pg -from PyQt5.QtCore import pyqtSignal, Qt -from PyQt5.QtGui import QRadialGradient, QColor -from PyQt5.QtWidgets import QLabel, QCheckBox +from pyqtgraph.Qt.QtCore import Signal, Qt +from pyqtgraph.Qt.QtGui import QRadialGradient, QColor +from pyqtgraph.Qt.QtWidgets import QLabel, QCheckBox from scipy.optimize import leastsq import scipy.optimize as optimize import numpy as np @@ -63,7 +63,7 @@ def __init__(self, title, description, imagepath, directory, clickEvent, parent= self.mousePressEvent = clickEvent class Gauge(QtWidgets.QWidget, QtWidgets.QGraphicsWidget): - valueChanged = QtCore.pyqtSignal(float) + valueChanged = QtCore.Signal(float) def __init__(self, parent=None, name=''): super(Gauge, self).__init__(parent)