From 8bd81d3b609770d8024ed185033fcd63c02d22df Mon Sep 17 00:00:00 2001 From: Andrew Reilley Date: Sun, 19 Mar 2023 00:14:42 -0400 Subject: [PATCH] Update to PyQt6, bump dependencies --- app.py | 8 ++--- main.py | 2 +- pyuic.json | 6 ++-- requirements.txt | 42 +++++++++++------------ uilib/converter.py | 6 ++-- uilib/converters/csvExporter.py | 2 +- uilib/converters/engExporter.py | 2 +- uilib/converters/imageExporter.py | 2 +- uilib/fileIO.py | 2 +- uilib/fileManager.py | 20 ++++++----- uilib/helpers.py | 4 +-- uilib/importExportManager.py | 5 ++- uilib/preferencesManager.py | 2 +- uilib/propellantManager.py | 2 +- uilib/simulationManager.py | 4 +-- uilib/tool.py | 4 +-- uilib/toolManager.py | 5 ++- uilib/widgets/aboutDialog.py | 2 +- uilib/widgets/channelSelector.py | 8 ++--- uilib/widgets/collectionEditor.py | 12 +++---- uilib/widgets/grainImageWidget.py | 6 ++-- uilib/widgets/grainPreviewGraph.py | 2 +- uilib/widgets/grainPreviewWidget.py | 4 +-- uilib/widgets/grainSelector.py | 10 +++--- uilib/widgets/mainWindow.py | 10 +++--- uilib/widgets/motorEditor.py | 2 +- uilib/widgets/nozzlePreviewWidget.py | 11 +++--- uilib/widgets/polygonEditor.py | 4 +-- uilib/widgets/preferencesMenu.py | 4 +-- uilib/widgets/propellantMenu.py | 22 +++++++----- uilib/widgets/propellantPreviewWidget.py | 4 +-- uilib/widgets/propellantTabEditor.py | 4 +-- uilib/widgets/propertyEditor.py | 6 ++-- uilib/widgets/resultsWidget.py | 4 +-- uilib/widgets/simulationAlertsDialog.py | 10 +++--- uilib/widgets/simulationProgressDialog.py | 4 +-- uilib/widgets/tabularEditor.py | 4 +-- 37 files changed, 128 insertions(+), 123 deletions(-) diff --git a/app.py b/app.py index 833c0d0..8d5c75d 100644 --- a/app.py +++ b/app.py @@ -1,7 +1,7 @@ import sys -from PyQt5.QtWidgets import QApplication, QMessageBox -from PyQt5.QtGui import QIcon +from PyQt6.QtWidgets import QApplication, QMessageBox +from PyQt6.QtGui import QIcon import motorlib from motorlib import simResult @@ -80,7 +80,7 @@ def outputMessage(self, content, title='openMotor'): msg.setWindowIcon(self.icon) msg.setText(content) msg.setWindowTitle(title) - msg.exec_() + msg.exec() def outputException(self, exception, text, title='openMotor - Error'): if self.headless: @@ -93,4 +93,4 @@ def outputException(self, exception, text, title='openMotor - Error'): msg.setText(text) msg.setInformativeText(str(exception)) msg.setWindowTitle(title) - msg.exec_() + msg.exec() diff --git a/main.py b/main.py index ebd8041..1ecf103 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,6 @@ import sys from app import App -from PyQt5.QtCore import Qt +from PyQt6.QtCore import Qt app = App(sys.argv) sys.exit(app.exec()) diff --git a/pyuic.json b/pyuic.json index e9a5be4..91c28ff 100644 --- a/pyuic.json +++ b/pyuic.json @@ -5,8 +5,6 @@ "uilib/views" ] ], - "pyrcc": "pyrcc5", - "pyrcc_options": "", - "pyuic": "pyuic5", - "pyuic_options": "--from-imports" + "pyuic": "pyuic6", + "pyuic_options": "" } \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 84ac525..77c55d5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,21 +1,21 @@ -appdirs -cycler -decorator -docopt -ezdxf -imageio -matplotlib -networkx -numpy -Pillow -pyparsing -pyqt-distutils -PyQt5 -PyQt5-sip -python-dateutil -PyYAML -scikit-fmm -scikit-image -scipy -six -sphinx +appdirs==1.4.4 +cycler==0.11.0 +decorator==5.1.1 +docopt==0.6.2 +ezdxf==1.0.3 +imageio==2.31.0 +matplotlib==3.7.1 +networkx==3.1 +numpy==1.24.3 +Pillow==9.5.0 +pyparsing==3.0.9 +pyqt-distutils==0.7.3 +PyQt6==6.4.2 +PyQt6-sip==13.4.1 +python-dateutil==2.8.2 +PyYAML==6.0 +scikit-fmm==2023.4.2 +scikit-image==0.21.0 +scipy==1.10.1 +six==1.16.0 +sphinx==7.0.1 diff --git a/uilib/converter.py b/uilib/converter.py index 765ce45..7f96c7b 100644 --- a/uilib/converter.py +++ b/uilib/converter.py @@ -1,6 +1,6 @@ -from PyQt5.QtCore import QObject -from PyQt5.QtWidgets import QFileDialog, QApplication -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtCore import QObject +from PyQt6.QtWidgets import QFileDialog, QApplication +from PyQt6.QtCore import pyqtSignal class Converter(QObject): def __init__(self, manager, name, description, fileTypes): diff --git a/uilib/converters/csvExporter.py b/uilib/converters/csvExporter.py index 3614787..4699ea0 100644 --- a/uilib/converters/csvExporter.py +++ b/uilib/converters/csvExporter.py @@ -1,4 +1,4 @@ -from PyQt5.QtWidgets import QDialog, QApplication +from PyQt6.QtWidgets import QDialog, QApplication from ..converter import Exporter diff --git a/uilib/converters/engExporter.py b/uilib/converters/engExporter.py index d5f02b3..411eac1 100644 --- a/uilib/converters/engExporter.py +++ b/uilib/converters/engExporter.py @@ -1,5 +1,5 @@ import xml.etree.ElementTree as ET -from PyQt5.QtWidgets import QDialog, QFileDialog, QDialogButtonBox, QApplication +from PyQt6.QtWidgets import QDialog, QFileDialog, QDialogButtonBox, QApplication from motorlib.properties import PropertyCollection, FloatProperty, StringProperty, EnumProperty import motorlib diff --git a/uilib/converters/imageExporter.py b/uilib/converters/imageExporter.py index 506aac3..d1e24ca 100644 --- a/uilib/converters/imageExporter.py +++ b/uilib/converters/imageExporter.py @@ -1,4 +1,4 @@ -from PyQt5.QtWidgets import QDialog, QApplication +from PyQt6.QtWidgets import QDialog, QApplication from motorlib.simResult import singleValueChannels, multiValueChannels from ..converter import Exporter diff --git a/uilib/fileIO.py b/uilib/fileIO.py index a5b94a0..f33a334 100644 --- a/uilib/fileIO.py +++ b/uilib/fileIO.py @@ -2,7 +2,7 @@ import os import platform -from PyQt5.QtWidgets import QApplication +from PyQt6.QtWidgets import QApplication import yaml import appdirs diff --git a/uilib/fileManager.py b/uilib/fileManager.py index e45337f..70e09b9 100644 --- a/uilib/fileManager.py +++ b/uilib/fileManager.py @@ -1,6 +1,6 @@ -from PyQt5.QtCore import QObject -from PyQt5.QtWidgets import QFileDialog, QMessageBox -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtCore import QObject +from PyQt6.QtWidgets import QFileDialog, QMessageBox +from PyQt6.QtCore import pyqtSignal import motorlib @@ -155,14 +155,18 @@ def unsavedCheck(self): msg.setWindowFlags(FLAGS_NO_ICON) msg.setText("The current file has unsaved changes. Close without saving?") msg.setWindowTitle("Close without saving?") - msg.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel) - - res = msg.exec_() - if res == QMessageBox.Save: + msg.setStandardButtons( + QMessageBox.StandardButton.Save + | QMessageBox.StandardButton.Discard + | QMessageBox.StandardButton.Cancel + ) + + res = msg.exec() + if res == QMessageBox.StandardButton.Save: self.save() return True - return res == QMessageBox.Discard + return res == QMessageBox.StandardButton.Discard # Outputs the filename component of the title def sendTitleUpdate(self): diff --git a/uilib/helpers.py b/uilib/helpers.py index a915103..8739f7a 100644 --- a/uilib/helpers.py +++ b/uilib/helpers.py @@ -1,3 +1,3 @@ -from PyQt5.QtCore import Qt +from PyQt6.QtCore import Qt -FLAGS_NO_ICON = Qt.Dialog | Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowCloseButtonHint +FLAGS_NO_ICON = Qt.WindowType.Dialog | Qt.WindowType.CustomizeWindowHint | Qt.WindowType.WindowTitleHint | Qt.WindowType.WindowCloseButtonHint diff --git a/uilib/importExportManager.py b/uilib/importExportManager.py index 0199ff5..a279358 100644 --- a/uilib/importExportManager.py +++ b/uilib/importExportManager.py @@ -1,6 +1,5 @@ -from PyQt5.QtCore import QObject -from PyQt5.QtWidgets import QAction -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtCore import pyqtSignal, QObject +from PyQt6.QtGui import QAction from .converter import Importer from .converters import BurnSimImporter, BurnSimExporter, EngExporter, CsvExporter, ImageExporter diff --git a/uilib/preferencesManager.py b/uilib/preferencesManager.py index b9734cc..52dea59 100644 --- a/uilib/preferencesManager.py +++ b/uilib/preferencesManager.py @@ -1,4 +1,4 @@ -from PyQt5.QtCore import QObject, pyqtSignal +from PyQt6.QtCore import QObject, pyqtSignal from motorlib.properties import PropertyCollection, FloatProperty, IntProperty, EnumProperty from motorlib.units import unitLabels, getAllConversions diff --git a/uilib/propellantManager.py b/uilib/propellantManager.py index 1da0d47..9c04e29 100644 --- a/uilib/propellantManager.py +++ b/uilib/propellantManager.py @@ -1,4 +1,4 @@ -from PyQt5.QtCore import QObject, pyqtSignal +from PyQt6.QtCore import QObject, pyqtSignal import motorlib diff --git a/uilib/simulationManager.py b/uilib/simulationManager.py index 6de6cbd..4bff93e 100644 --- a/uilib/simulationManager.py +++ b/uilib/simulationManager.py @@ -1,7 +1,7 @@ from threading import Thread -from PyQt5.QtCore import QObject -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtCore import QObject +from PyQt6.QtCore import pyqtSignal from .widgets.simulationAlertsDialog import SimulationAlertsDialog from .widgets.simulationProgressDialog import SimulationProgressDialog diff --git a/uilib/tool.py b/uilib/tool.py index 4f32e0a..640b49f 100644 --- a/uilib/tool.py +++ b/uilib/tool.py @@ -1,5 +1,5 @@ -from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel, QApplication -from PyQt5.QtGui import QIcon +from PyQt6.QtWidgets import QDialog, QVBoxLayout, QLabel, QApplication +from PyQt6.QtGui import QIcon import motorlib diff --git a/uilib/toolManager.py b/uilib/toolManager.py index 2c91f1f..5da57e2 100644 --- a/uilib/toolManager.py +++ b/uilib/toolManager.py @@ -1,6 +1,5 @@ -from PyQt5.QtCore import QObject -from PyQt5.QtWidgets import QAction -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtCore import QObject, pyqtSignal +from PyQt6.QtGui import QAction from .tools import ChangeDiameterTool, InitialKNTool, MaxKNTool from .tools import ExpansionTool diff --git a/uilib/widgets/aboutDialog.py b/uilib/widgets/aboutDialog.py index f598cde..884748f 100644 --- a/uilib/widgets/aboutDialog.py +++ b/uilib/widgets/aboutDialog.py @@ -1,4 +1,4 @@ -from PyQt5.QtWidgets import QDialog, QApplication +from PyQt6.QtWidgets import QDialog, QApplication from ..views.AboutDialog_ui import Ui_AboutDialog diff --git a/uilib/widgets/channelSelector.py b/uilib/widgets/channelSelector.py index 8569050..decc702 100644 --- a/uilib/widgets/channelSelector.py +++ b/uilib/widgets/channelSelector.py @@ -1,5 +1,5 @@ -from PyQt5.QtWidgets import QGroupBox, QCheckBox, QRadioButton, QVBoxLayout -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtWidgets import QGroupBox, QCheckBox, QRadioButton, QVBoxLayout +from PyQt6.QtCore import pyqtSignal, Qt import motorlib @@ -27,7 +27,7 @@ def setupChecks(self, multiselect, disabled=[], default=None, exclude=[]): if default is not None: if multiselect: if channel in default: - self.checks[channel].setCheckState(2) + self.checks[channel].setCheckState(Qt.CheckState.Checked) else: self.checks[channel].setChecked(channel == default) self.checks[channel].toggled.connect(self.checksChanged.emit) @@ -56,7 +56,7 @@ def resetChecks(self): def unselect(self, channels): for channel in channels: if channel in self.checks.keys(): - self.checks[channel].setCheckState(0) + self.checks[channel].setCheckState(Qt.CheckState.Unchecked) def toggleEnabled(self, channels, enabled): for channel in channels: diff --git a/uilib/widgets/collectionEditor.py b/uilib/widgets/collectionEditor.py index 18cc46e..aa15a9d 100644 --- a/uilib/widgets/collectionEditor.py +++ b/uilib/widgets/collectionEditor.py @@ -1,7 +1,7 @@ -from PyQt5.QtWidgets import QWidget, QFormLayout, QVBoxLayout, QHBoxLayout -from PyQt5.QtWidgets import QLabel, QPushButton -from PyQt5.QtWidgets import QSpacerItem, QSizePolicy -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtWidgets import QWidget, QFormLayout, QVBoxLayout, QHBoxLayout +from PyQt6.QtWidgets import QLabel, QPushButton +from PyQt6.QtWidgets import QSpacerItem, QSizePolicy +from PyQt6.QtCore import pyqtSignal from .propertyEditor import PropertyEditor @@ -27,7 +27,7 @@ def __init__(self, parent, buttons=False): self.layout().addLayout(self.stats) - self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) + self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding) self.layout().addItem(self.verticalSpacer) self.buttons = buttons @@ -71,7 +71,7 @@ def loadProperties(self, obj): self.propertyEditors[prop] = PropertyEditor(self, obj.props[prop], self.preferences) self.propertyEditors[prop].valueChanged.connect(self.propertyUpdate) label = QLabel('{}:'.format(obj.props[prop].dispName)) - label.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding) + label.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding) self.form.addRow(label, self.propertyEditors[prop]) if self.buttons: self.applyButton.show() diff --git a/uilib/widgets/grainImageWidget.py b/uilib/widgets/grainImageWidget.py index 6a26317..2bdb19a 100644 --- a/uilib/widgets/grainImageWidget.py +++ b/uilib/widgets/grainImageWidget.py @@ -1,5 +1,5 @@ -from PyQt5.QtWidgets import QLabel -from PyQt5.QtGui import QPixmap, QImage +from PyQt6.QtWidgets import QLabel +from PyQt6.QtGui import QPixmap, QImage import numpy as np class GrainImageWidget(QLabel): @@ -8,6 +8,6 @@ def showImage(self, image): image = np.logical_not(image.filled()) image = image.astype(np.uint8) * 255 height, width = image.shape - qImg = QImage(image.data, width, height, QImage.Format_Grayscale8) + qImg = QImage(image.data, width, height, QImage.Format.Format_Grayscale8) pixmap = QPixmap(qImg) self.setPixmap(pixmap) diff --git a/uilib/widgets/grainPreviewGraph.py b/uilib/widgets/grainPreviewGraph.py index 89eb6c0..e32b598 100644 --- a/uilib/widgets/grainPreviewGraph.py +++ b/uilib/widgets/grainPreviewGraph.py @@ -38,7 +38,7 @@ def cleanup(self): self.image = None if self.numContours > 0: for _ in range(0, self.numContours): - self.plot.lines.pop(0) + self.plot.lines[0].remove() self.numContours = 0 self.draw() diff --git a/uilib/widgets/grainPreviewWidget.py b/uilib/widgets/grainPreviewWidget.py index 2055c0d..9ea15a7 100644 --- a/uilib/widgets/grainPreviewWidget.py +++ b/uilib/widgets/grainPreviewWidget.py @@ -1,7 +1,7 @@ from threading import Thread -from PyQt5.QtWidgets import QWidget -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtWidgets import QWidget +from PyQt6.QtCore import pyqtSignal import motorlib diff --git a/uilib/widgets/grainSelector.py b/uilib/widgets/grainSelector.py index b46b976..d4a1cfe 100644 --- a/uilib/widgets/grainSelector.py +++ b/uilib/widgets/grainSelector.py @@ -1,5 +1,5 @@ -from PyQt5.QtWidgets import QGroupBox, QCheckBox, QRadioButton, QVBoxLayout -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtWidgets import QGroupBox, QCheckBox, QRadioButton, QVBoxLayout +from PyQt6.QtCore import pyqtSignal, Qt class GrainSelector(QGroupBox): @@ -23,7 +23,7 @@ def setupChecks(self, simRes, multiselect): checkTitle = "Grain " + str(gid + 1) if multiselect: check = QCheckBox(checkTitle) - check.setCheckState(2) + check.setCheckState(Qt.CheckState.Checked) else: check = QRadioButton(checkTitle) self.layout().addWidget(check) @@ -46,6 +46,6 @@ def getUnselectedGrains(self): def setChecks(self, checks): for check in self.checks: - check.setCheckState(0) + check.setCheckState(Qt.CheckState.Unchecked) for check in checks: - self.checks[check].setCheckState(2) + self.checks[check].setCheckState(Qt.CheckState.Checked) diff --git a/uilib/widgets/mainWindow.py b/uilib/widgets/mainWindow.py index e2589ff..0b78237 100644 --- a/uilib/widgets/mainWindow.py +++ b/uilib/widgets/mainWindow.py @@ -1,7 +1,7 @@ import sys -from PyQt5.QtWidgets import QWidget, QMainWindow, QTableWidgetItem, QHeaderView, QTableWidget -from PyQt5.QtCore import Qt +from PyQt6.QtWidgets import QWidget, QMainWindow, QTableWidgetItem, QHeaderView, QTableWidget +from PyQt6.QtCore import Qt import motorlib import uilib.widgets.aboutDialog @@ -132,8 +132,8 @@ def setupGrainTable(self): self.ui.tableWidgetGrainList.clearContents() header = self.ui.tableWidgetGrainList.horizontalHeader() - header.setSectionResizeMode(0, QHeaderView.ResizeToContents) - header.setSectionResizeMode(1, QHeaderView.Stretch) + header.setSectionResizeMode(0, QHeaderView.ResizeMode.ResizeToContents) + header.setSectionResizeMode(1, QHeaderView.ResizeMode.Stretch) self.updateGrainTable() @@ -381,6 +381,6 @@ def applyPreferences(self, prefDict): self.setupGraph() def keyPressEvent(self, event): - if event.key() == Qt.Key_Delete or event.key() == Qt.Key_Backspace: + if event.key() == Qt.Key.Key_Delete or event.key() == Qt.Key.Key_Backspace: if len(self.ui.tableWidgetGrainList.selectedItems()) != 0: self.deleteGrain() diff --git a/uilib/widgets/motorEditor.py b/uilib/widgets/motorEditor.py index 6631c5f..2dbafea 100644 --- a/uilib/widgets/motorEditor.py +++ b/uilib/widgets/motorEditor.py @@ -1,4 +1,4 @@ -from PyQt5.QtWidgets import QLabel +from PyQt6.QtWidgets import QLabel import motorlib.grain import motorlib.nozzle diff --git a/uilib/widgets/nozzlePreviewWidget.py b/uilib/widgets/nozzlePreviewWidget.py index aec1496..ae647d0 100644 --- a/uilib/widgets/nozzlePreviewWidget.py +++ b/uilib/widgets/nozzlePreviewWidget.py @@ -1,8 +1,8 @@ from math import radians, tan -from PyQt5.QtWidgets import QWidget, QApplication, QGraphicsScene, QGraphicsPolygonItem -from PyQt5.QtGui import QPolygonF, QBrush -from PyQt5.QtCore import QPointF, Qt +from PyQt6.QtWidgets import QWidget, QApplication, QGraphicsScene, QGraphicsPolygonItem +from PyQt6.QtGui import QPolygonF, QBrush +from PyQt6.QtCore import QPointF, Qt import motorlib from ..views.NozzlePreview_ui import Ui_NozzlePreview @@ -14,7 +14,8 @@ def __init__(self): self.ui.setupUi(self) self.brush = QBrush() - self.brush.setStyle(1) + + self.brush.setStyle(Qt.BrushStyle.SolidPattern) self.scene = QGraphicsScene(self) self.upper = QGraphicsPolygonItem() self.lower = QGraphicsPolygonItem() @@ -82,4 +83,4 @@ def loadNozzle(self, nozzle): def rescale(self): self.scene.setSceneRect(self.scene.itemsBoundingRect()) - self.ui.tabCrossSection.fitInView(self.scene.sceneRect(), Qt.KeepAspectRatio) + self.ui.tabCrossSection.fitInView(self.scene.sceneRect(), Qt.AspectRatioMode.KeepAspectRatio) diff --git a/uilib/widgets/polygonEditor.py b/uilib/widgets/polygonEditor.py index 66babef..0d6401c 100644 --- a/uilib/widgets/polygonEditor.py +++ b/uilib/widgets/polygonEditor.py @@ -1,8 +1,8 @@ import math import itertools -from PyQt5.QtWidgets import QWidget, QPushButton, QHBoxLayout, QFileDialog, QApplication -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtWidgets import QWidget, QPushButton, QHBoxLayout, QFileDialog, QApplication +from PyQt6.QtCore import pyqtSignal import ezdxf import motorlib diff --git a/uilib/widgets/preferencesMenu.py b/uilib/widgets/preferencesMenu.py index 4bda288..65f4dc9 100644 --- a/uilib/widgets/preferencesMenu.py +++ b/uilib/widgets/preferencesMenu.py @@ -1,5 +1,5 @@ -from PyQt5.QtWidgets import QDialog, QApplication -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtWidgets import QDialog, QApplication +from PyQt6.QtCore import pyqtSignal from ..views.Preferences_ui import Ui_PreferencesDialog diff --git a/uilib/widgets/propellantMenu.py b/uilib/widgets/propellantMenu.py index 31050a5..d61b1fc 100644 --- a/uilib/widgets/propellantMenu.py +++ b/uilib/widgets/propellantMenu.py @@ -1,7 +1,7 @@ -from PyQt5.QtWidgets import QDialog, QMessageBox, QApplication -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtWidgets import QDialog, QMessageBox, QApplication +from PyQt6.QtCore import pyqtSignal from ..helpers import FLAGS_NO_ICON -from PyQt5.QtCore import Qt +from PyQt6.QtCore import Qt import motorlib.propellant @@ -126,15 +126,19 @@ def unsavedCheck(self): msg.setWindowFlags(FLAGS_NO_ICON); msg.setText("Close without saving current propellant?") msg.setWindowTitle("Close without saving?") - msg.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel) - - res = msg.exec_() - if res == QMessageBox.Save: + msg.setStandardButtons( + QMessageBox.StandardButton.Save + | QMessageBox.StandardButton.Discard + | QMessageBox.StandardButton.Cancel + ) + + res = msg.exec() + if res == QMessageBox.StandardButton.Save: self.propEdited(self.ui.propEditor.getProperties()) return True - return res == QMessageBox.Discard + return res == QMessageBox.StandardButton.Discard def keyPressEvent(self, event): - if event.key() == Qt.Key_Delete or event.key() == Qt.Key_Backspace: + if event.key() == Qt.Key.Key_Delete or event.key() == Qt.Key.Key_Backspace: if len(self.ui.listWidgetPropellants.selectedItems()) != 0: self.deleteProp() diff --git a/uilib/widgets/propellantPreviewWidget.py b/uilib/widgets/propellantPreviewWidget.py index b6a3420..3735b05 100644 --- a/uilib/widgets/propellantPreviewWidget.py +++ b/uilib/widgets/propellantPreviewWidget.py @@ -1,5 +1,5 @@ -from PyQt5.QtWidgets import QWidget -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtWidgets import QWidget +from PyQt6.QtCore import pyqtSignal import motorlib diff --git a/uilib/widgets/propellantTabEditor.py b/uilib/widgets/propellantTabEditor.py index b93846b..6b7cc54 100644 --- a/uilib/widgets/propellantTabEditor.py +++ b/uilib/widgets/propellantTabEditor.py @@ -1,5 +1,5 @@ -from PyQt5.QtWidgets import QLabel -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtWidgets import QLabel +from PyQt6.QtCore import pyqtSignal from motorlib.units import convert from motorlib.propellant import PropellantTab diff --git a/uilib/widgets/propertyEditor.py b/uilib/widgets/propertyEditor.py index 8678836..1b27868 100644 --- a/uilib/widgets/propertyEditor.py +++ b/uilib/widgets/propertyEditor.py @@ -1,8 +1,8 @@ import math -from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLineEdit -from PyQt5.QtWidgets import QDoubleSpinBox, QSpinBox, QComboBox -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtWidgets import QWidget, QVBoxLayout, QLineEdit +from PyQt6.QtWidgets import QDoubleSpinBox, QSpinBox, QComboBox +from PyQt6.QtCore import pyqtSignal import motorlib diff --git a/uilib/widgets/resultsWidget.py b/uilib/widgets/resultsWidget.py index b23aaa3..ce79261 100644 --- a/uilib/widgets/resultsWidget.py +++ b/uilib/widgets/resultsWidget.py @@ -1,4 +1,4 @@ -from PyQt5.QtWidgets import QWidget, QHeaderView, QLabel +from PyQt6.QtWidgets import QWidget, QHeaderView, QLabel import numpy as np import motorlib @@ -99,7 +99,7 @@ def updateGrainTab(self): self.grainImageWidgets[gid].showImage(image) else: self.grainImageWidgets[gid].setText('-') - self.ui.tableWidgetGrains.horizontalHeader().setSectionResizeMode(gid, QHeaderView.ResizeToContents) + self.ui.tableWidgetGrains.horizontalHeader().setSectionResizeMode(gid, QHeaderView.ResizeMode.ResizeToContents) for field in self.grainTableFields: fromUnit = self.simResult.channels[field].unit toUnit = self.preferences.getUnit(fromUnit) diff --git a/uilib/widgets/simulationAlertsDialog.py b/uilib/widgets/simulationAlertsDialog.py index 880d1cb..ea9b4e8 100644 --- a/uilib/widgets/simulationAlertsDialog.py +++ b/uilib/widgets/simulationAlertsDialog.py @@ -1,4 +1,4 @@ -from PyQt5.QtWidgets import QDialog, QTableWidgetItem, QHeaderView, QApplication +from PyQt6.QtWidgets import QDialog, QTableWidgetItem, QHeaderView, QApplication from motorlib.simResult import alertLevelNames, alertTypeNames @@ -13,10 +13,10 @@ def __init__(self): self.setWindowIcon(QApplication.instance().icon) header = self.ui.tableWidgetAlerts.horizontalHeader() - header.setSectionResizeMode(0, QHeaderView.ResizeToContents) - header.setSectionResizeMode(1, QHeaderView.ResizeToContents) - header.setSectionResizeMode(2, QHeaderView.ResizeToContents) - header.setSectionResizeMode(3, QHeaderView.Stretch) + header.setSectionResizeMode(0, QHeaderView.ResizeMode.ResizeToContents) + header.setSectionResizeMode(1, QHeaderView.ResizeMode.ResizeToContents) + header.setSectionResizeMode(2, QHeaderView.ResizeMode.ResizeToContents) + header.setSectionResizeMode(3, QHeaderView.ResizeMode.Stretch) self.hide() diff --git a/uilib/widgets/simulationProgressDialog.py b/uilib/widgets/simulationProgressDialog.py index c099a1f..a782721 100644 --- a/uilib/widgets/simulationProgressDialog.py +++ b/uilib/widgets/simulationProgressDialog.py @@ -1,5 +1,5 @@ -from PyQt5.QtWidgets import QDialog, QApplication -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtWidgets import QDialog, QApplication +from PyQt6.QtCore import pyqtSignal from ..views.SimulatingDialog_ui import Ui_SimProgressDialog diff --git a/uilib/widgets/tabularEditor.py b/uilib/widgets/tabularEditor.py index fe456ee..e50d371 100644 --- a/uilib/widgets/tabularEditor.py +++ b/uilib/widgets/tabularEditor.py @@ -1,5 +1,5 @@ -from PyQt5.QtWidgets import QWidget -from PyQt5.QtCore import pyqtSignal +from PyQt6.QtWidgets import QWidget +from PyQt6.QtCore import pyqtSignal from motorlib.propellant import PropellantTab