From 1995e91dbfa1de4b1ff9a820878387e9e66a67d4 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 3 Jan 2025 09:58:07 +0100 Subject: [PATCH 1/4] Edits for Qt6 - plus debugging that needs further work --- tools/Python/mcgui/mcgui.py | 2 ++ tools/Python/mcgui/viewclasses.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/Python/mcgui/mcgui.py b/tools/Python/mcgui/mcgui.py index 7d5d36ab8..30c00525b 100755 --- a/tools/Python/mcgui/mcgui.py +++ b/tools/Python/mcgui/mcgui.py @@ -18,6 +18,7 @@ from PyQt6.QtWidgets import QApplication, QWidget from PyQt6.QtGui import QFont, QFontDatabase import PyQt6 as PyQt + print("Importing Qt6 OK") try: from PyQt6 import Qsci except ImportError: @@ -28,6 +29,7 @@ from PyQt5.QtWidgets import QApplication, QWidget from PyQt5.QtGui import QFont, QFontDatabase import PyQt5 as PyQt + print("importing Qt5 OK") try: from PyQt5 import Qsci except ImportError: diff --git a/tools/Python/mcgui/viewclasses.py b/tools/Python/mcgui/viewclasses.py index 07c4421e5..5faa35697 100644 --- a/tools/Python/mcgui/viewclasses.py +++ b/tools/Python/mcgui/viewclasses.py @@ -314,7 +314,7 @@ def __sbEventFilter(subject, object, event): edt = QtWidgets.QLineEdit() edt = subject # handle focus on - if event.type() == QtCore.QEvent.FocusIn: + if event.type() == QtCore.QEvent.Type.FocusIn: if edt.text() == 'search...': edt.setText('') font = QtGui.QFont() @@ -323,7 +323,7 @@ def __sbEventFilter(subject, object, event): edt.setStyleSheet("color: black;") # handle focus off - elif event.type() == QtCore.QEvent.FocusOut: + elif event.type() == QtCore.QEvent.Type.FocusOut: if edt.text() == '': font = QtGui.QFont() font.setItalic(True) @@ -332,7 +332,7 @@ def __sbEventFilter(subject, object, event): edt.setText('search...') # handle enter keypress (search) - elif event.type() == QtCore.QEvent.KeyPress: + elif event.type() == QtCore.QEvent.Type.KeyPress: # return & enter if event.key() in [0x01000004, 0x01000005]: self.__search(subject.text().casefold()) @@ -503,7 +503,7 @@ def __initScintilla(self): font.setPointSize(int(mccode_config.configuration["GUIFONTSIZE"])) # brace matching - scintilla.setBraceMatching(Qsci.QsciScintilla.SloppyBraceMatch) + scintilla.setBraceMatching(Qsci.QsciScintilla.BraceMatch.SloppyBraceMatch) # set lexer lexer = Qsci.QsciLexerCPP() @@ -518,14 +518,14 @@ def __initScintilla(self): scintilla.__myApi = Qsci.QsciAPIs(lexer) scintilla.setAutoCompletionThreshold(1) - scintilla.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs) + scintilla.setAutoCompletionSource(Qsci.QsciScintilla.AutoCompletionSource.AcsAPIs) # remove horizontal scrollbar scintilla.SendScintilla(Qsci.QsciScintilla.SCI_SETHSCROLLBAR, 0) # display default line numbers fm = QtGui.QFontMetrics(font) - scintilla.setMarginWidth(0, fm.width( "00000" )) + scintilla.setMarginWidth(0, fm.horizontalAdvance( "00000" )) scintilla.setMarginLineNumbers(0, True) ######################## @@ -595,7 +595,7 @@ def __initCallbacks(self): # TODO: create a ctr-a on a menu to __scintilla.selectAll(bool select) def __keyEventFilterFct(subject, object, event): - if event.type() == QtCore.QEvent.KeyRelease: + if event.type() == QtCore.QEvent.Type.KeyRelease: # ctrl-q if event.key() == 81 and int(event.modifiers()) == 67108864: self.close() @@ -1024,7 +1024,7 @@ def _wEventFilter(subject, object, event): edt = QtWidgets.QLineEdit() edt = subject # handle focus on - if event.type() == QtCore.QEvent.FocusIn: + if event.type() == QtCore.QEvent.Type.FocusIn: if edt.text() == edt.defval: edt.setText('') font = QtGui.QFont() @@ -1034,7 +1034,7 @@ def _wEventFilter(subject, object, event): edt.setCursorPosition(0) # handle focus off - elif event.type() == QtCore.QEvent.FocusOut: + elif event.type() == QtCore.QEvent.Type.FocusOut: if edt.text() == '': font = QtGui.QFont() font.setItalic(True) From b551f8da9f27196a5be7569bee02cc3d745aba7d Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 3 Jan 2025 10:07:08 +0100 Subject: [PATCH 2/4] Remove debugging --- tools/Python/mcgui/mcgui.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Python/mcgui/mcgui.py b/tools/Python/mcgui/mcgui.py index 30c00525b..6e47bca39 100755 --- a/tools/Python/mcgui/mcgui.py +++ b/tools/Python/mcgui/mcgui.py @@ -18,7 +18,7 @@ from PyQt6.QtWidgets import QApplication, QWidget from PyQt6.QtGui import QFont, QFontDatabase import PyQt6 as PyQt - print("Importing Qt6 OK") + try: from PyQt6 import Qsci except ImportError: @@ -29,7 +29,7 @@ from PyQt5.QtWidgets import QApplication, QWidget from PyQt5.QtGui import QFont, QFontDatabase import PyQt5 as PyQt - print("importing Qt5 OK") + try: from PyQt5 import Qsci except ImportError: From 44cc52b2e89ed4e1b2fa46e021bfe92ebce6082e Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 3 Jan 2025 10:10:04 +0100 Subject: [PATCH 3/4] Switch DEB dependencies toward qt6 --- tools/Python/mcgui/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Python/mcgui/CMakeLists.txt b/tools/Python/mcgui/CMakeLists.txt index a733c4f8c..4a84f731b 100644 --- a/tools/Python/mcgui/CMakeLists.txt +++ b/tools/Python/mcgui/CMakeLists.txt @@ -52,7 +52,7 @@ set(CPACK_NSIS_DISPLAY_NAME "${NSIS_NAME}") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${NSIS_NAME}") # Debian -set(CPACK_DEBIAN_PACKAGE_DEPENDS "${FLAVOR}, ${FLAVOR}-tools-python-${P}doc, ${FLAVOR}-tools-python-mccodelib, python3, python3-pyqt5.qsci") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "${FLAVOR}, ${FLAVOR}-tools-python-${P}doc, ${FLAVOR}-tools-python-mccodelib, python3, python3-pyqt6.qsci") set(CPACK_DEBIAN_PACKAGE_REPLACES "${FLAVOR}-tools-python-${P}gui-3.5.1") # RPM From f0917dbcbcda50c8ec7d22fe0e3b9da03e42ba79 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 3 Jan 2025 11:44:33 +0100 Subject: [PATCH 4/4] Attempt pyqt5->6 replacement in matplotlib plotter for deb systems --- tools/Python/mcplot/matplotlib/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Python/mcplot/matplotlib/CMakeLists.txt b/tools/Python/mcplot/matplotlib/CMakeLists.txt index 751dcf2b9..86cc2a54b 100644 --- a/tools/Python/mcplot/matplotlib/CMakeLists.txt +++ b/tools/Python/mcplot/matplotlib/CMakeLists.txt @@ -52,7 +52,7 @@ set(CPACK_NSIS_DISPLAY_NAME "${NSIS_NAME}") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${NSIS_NAME}") # Debian -set(CPACK_DEBIAN_PACKAGE_DEPENDS "${FLAVOR}, python3-matplotlib, python3-pyqt5, python3-mplexporter, python3-tornado") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "${FLAVOR}, python3-matplotlib, python3-pyqt6, python3-mplexporter, python3-tornado") set(CPACK_DEBIAN_PACKAGE_REPLACES "${FLAVOR}-tools-python-${P}plot-matplotlib-3.5.1") # RPM