Skip to content

Commit

Permalink
Update to PyQt6, bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
reilleya committed Sep 29, 2023
1 parent 1286748 commit 8af88ed
Show file tree
Hide file tree
Showing 38 changed files with 129 additions and 124 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ You can download the latest version for your system [here](https://github.com/re

Building from Source
--------------------
The program is currently being developed using python 3.10. The dependencies are outlined in `requirements.txt`, the main ones include `PyQt5`, `matplot`, `numpy`, `scipy`, `scikit-fmm`, and `scikit-image`. Because the PyQt5 bindings are used for the GUI, Qt5 must also be installed.
The program is currently being developed using python 3.10. The dependencies are outlined in `requirements.txt`, the main ones include `PyQt6`, `matplot`, `numpy`, `scipy`, `scikit-fmm`, and `scikit-image`. Because the PyQt6 bindings are used for the GUI, Qt6 must also be installed.

The easiest way to build/run from source code is to clone the repository and install the required dependencies into a virtual enviornment:
```
Expand Down
8 changes: 4 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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()
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -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())
6 changes: 2 additions & 4 deletions pyuic.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"uilib/views"
]
],
"pyrcc": "pyrcc5",
"pyrcc_options": "",
"pyuic": "pyuic5",
"pyuic_options": "--from-imports"
"pyuic": "pyuic6",
"pyuic_options": ""
}
42 changes: 21 additions & 21 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions uilib/converter.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion uilib/converters/csvExporter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PyQt5.QtWidgets import QDialog, QApplication
from PyQt6.QtWidgets import QDialog, QApplication

from ..converter import Exporter

Expand Down
2 changes: 1 addition & 1 deletion uilib/converters/engExporter.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion uilib/converters/imageExporter.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion uilib/fileIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import platform

from PyQt5.QtWidgets import QApplication
from PyQt6.QtWidgets import QApplication
import yaml
import appdirs

Expand Down
20 changes: 12 additions & 8 deletions uilib/fileManager.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions uilib/helpers.py
Original file line number Diff line number Diff line change
@@ -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
5 changes: 2 additions & 3 deletions uilib/importExportManager.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion uilib/preferencesManager.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion uilib/propellantManager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PyQt5.QtCore import QObject, pyqtSignal
from PyQt6.QtCore import QObject, pyqtSignal

import motorlib

Expand Down
4 changes: 2 additions & 2 deletions uilib/simulationManager.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions uilib/tool.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 2 additions & 3 deletions uilib/toolManager.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion uilib/widgets/aboutDialog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PyQt5.QtWidgets import QDialog, QApplication
from PyQt6.QtWidgets import QDialog, QApplication
from ..views.AboutDialog_ui import Ui_AboutDialog


Expand Down
8 changes: 4 additions & 4 deletions uilib/widgets/channelSelector.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions uilib/widgets/collectionEditor.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions uilib/widgets/grainImageWidget.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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)
2 changes: 1 addition & 1 deletion uilib/widgets/grainPreviewGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions uilib/widgets/grainPreviewWidget.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
10 changes: 5 additions & 5 deletions uilib/widgets/grainSelector.py
Original file line number Diff line number Diff line change
@@ -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):

Expand All @@ -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)
Expand All @@ -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)
10 changes: 5 additions & 5 deletions uilib/widgets/mainWindow.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()
2 changes: 1 addition & 1 deletion uilib/widgets/motorEditor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PyQt5.QtWidgets import QLabel
from PyQt6.QtWidgets import QLabel

import motorlib.grain
import motorlib.nozzle
Expand Down
Loading

0 comments on commit 8af88ed

Please sign in to comment.