fix: PyQt6 fixes (#629)

More fixes for PyQt6 should now be usable again with >python3.7 & PyQt6

Calibration - tested
Display Configuration - tested
pull/634/head
Henk Vergonet 2023-04-18 12:14:21 +02:00 zatwierdzone przez GitHub
rodzic d09b55e1ae
commit 8f86722c1e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
9 zmienionych plików z 45 dodań i 45 usunięć

Wyświetl plik

@ -502,7 +502,7 @@ class FrequencyChart(Chart):
and (not self.reference or self._data_oob(self.reference)) and (not self.reference or self._data_oob(self.reference))
): ):
# Data outside frequency range # Data outside frequency range
qp.setBackgroundMode(Qt.OpaqueMode) qp.setBackgroundMode(Qt.BGMode.OpaqueMode)
qp.setBackground(Chart.color.background) qp.setBackground(Chart.color.background)
qp.setPen(Chart.color.text) qp.setPen(Chart.color.text)
qp.drawText( qp.drawText(
@ -512,7 +512,7 @@ class FrequencyChart(Chart):
) )
def drawDragbog(self, qp: QtGui.QPainter): def drawDragbog(self, qp: QtGui.QPainter):
dashed_pen = QtGui.QPen(Chart.color.foreground, 1, Qt.DashLine) dashed_pen = QtGui.QPen(Chart.color.foreground, 1, Qt.PenStyle.DashLine)
qp.setPen(dashed_pen) qp.setPen(dashed_pen)
top_left = QtCore.QPoint( top_left = QtCore.QPoint(
self.dragbox.pos_start[0], self.dragbox.pos_start[1] self.dragbox.pos_start[0], self.dragbox.pos_start[1]

Wyświetl plik

@ -479,7 +479,7 @@ class TDRChart(Chart):
self._draw_graph(height, width) self._draw_graph(height, width)
if self.dragbox.state and self.dragbox.pos[0] != -1: if self.dragbox.state and self.dragbox.pos[0] != -1:
dashed_pen = QPen(Chart.color.foreground, 1, Qt.DashLine) dashed_pen = QPen(Chart.color.foreground, 1, Qt.PenStyle.DashLine)
qp.setPen(dashed_pen) qp.setPen(dashed_pen)
qp.drawRect( qp.drawRect(
QRect( QRect(

Wyświetl plik

@ -91,7 +91,7 @@ class NanoVNA(VNA):
rgba_array, rgba_array,
self.screenwidth, self.screenwidth,
self.screenheight, self.screenheight,
QImage.Format_ARGB32, QImage.Format.Format_ARGB32,
) )
logger.debug("Captured screenshot") logger.debug("Captured screenshot")
return QPixmap(image) return QPixmap(image)

Wyświetl plik

@ -304,7 +304,7 @@ class NanoVNASaver(QWidget):
self.marker_data_layout.addWidget(m.get_data_layout()) self.marker_data_layout.addWidget(m.get_data_layout())
scroll2 = QtWidgets.QScrollArea() scroll2 = QtWidgets.QScrollArea()
# scroll2.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) # scroll2.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
scroll2.setWidgetResizable(True) scroll2.setWidgetResizable(True)
scroll2.setVisible(True) scroll2.setVisible(True)

Wyświetl plik

@ -106,7 +106,7 @@ class BandsModel(QtCore.QAbstractTableModel):
def setData( def setData(
self, index: QModelIndex, value: typing.Any, role: int = ... self, index: QModelIndex, value: typing.Any, role: int = ...
) -> bool: ) -> bool:
if role == QtCore.Qt.EditRole and index.isValid(): if role == QtCore.Qt.ItemDataRole.EditRole and index.isValid():
t = self.bands[index.row()] t = self.bands[index.row()]
name = t[0] name = t[0]
start = t[1] start = t[1]

Wyświetl plik

@ -63,10 +63,10 @@ class BandsWindow(QtWidgets.QWidget):
def resetBands(self): def resetBands(self):
confirm = QtWidgets.QMessageBox( confirm = QtWidgets.QMessageBox(
QtWidgets.QMessageBox.Warning, QtWidgets.QMessageBox.Icon.Warning,
"Confirm reset", "Confirm reset",
"Are you sure you want to reset the bands to default?", "Are you sure you want to reset the bands to default?",
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.Cancel,
).exec() ).exec()
if confirm == QtWidgets.QMessageBox.Yes: if confirm == QtWidgets.QMessageBox.StandardButton.Yes:
self.app.bands.resetBands() self.app.bands.resetBands()

Wyświetl plik

@ -282,11 +282,11 @@ class CalibrationWindow(QtWidgets.QWidget):
"If you are certain you know what you are doing, click" "If you are certain you know what you are doing, click"
" Yes." " Yes."
), ),
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.Cancel,
QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.StandardButton.Cancel,
) )
if response == QtWidgets.QMessageBox.Yes: if response == QtWidgets.QMessageBox.StandardButton.Yes:
self.app.settings.setValue("ExpertCalibrationUser", True) self.app.settings.setValue("ExpertCalibrationUser", True)
return True return True
return False return False
@ -677,7 +677,7 @@ class CalibrationWindow(QtWidgets.QWidget):
filedialog = QtWidgets.QFileDialog(self) filedialog = QtWidgets.QFileDialog(self)
filedialog.setDefaultSuffix("cal") filedialog.setDefaultSuffix("cal")
filedialog.setNameFilter("Calibration Files (*.cal);;All files (*.*)") filedialog.setNameFilter("Calibration Files (*.cal);;All files (*.*)")
filedialog.setAcceptMode(QtWidgets.QFileDialog.AcceptSave) filedialog.setAcceptMode(QtWidgets.QFileDialog.AcceptMode.AcceptSave)
if filedialog.exec(): if filedialog.exec():
filename = filedialog.selectedFiles()[0] filename = filedialog.selectedFiles()[0]
else: else:
@ -707,7 +707,7 @@ class CalibrationWindow(QtWidgets.QWidget):
def automaticCalibration(self): def automaticCalibration(self):
self.btn_automatic.setDisabled(True) self.btn_automatic.setDisabled(True)
introduction = QtWidgets.QMessageBox( introduction = QtWidgets.QMessageBox(
QtWidgets.QMessageBox.Information, QtWidgets.QMessageBox.Icon.Information,
"Calibration assistant", "Calibration assistant",
( (
"This calibration assistant will help you create a calibration" "This calibration assistant will help you create a calibration"
@ -723,16 +723,16 @@ class CalibrationWindow(QtWidgets.QWidget):
" to save slot 0 before starting.</b><br><br>" " to save slot 0 before starting.</b><br><br>"
"Once you are ready to proceed, press Ok." "Once you are ready to proceed, press Ok."
), ),
QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel,
) )
response = introduction.exec() response = introduction.exec()
if response != QtWidgets.QMessageBox.Ok: if response != QtWidgets.QMessageBox.StandardButton.Ok:
self.btn_automatic.setDisabled(False) self.btn_automatic.setDisabled(False)
return return
logger.info("Starting automatic calibration assistant.") logger.info("Starting automatic calibration assistant.")
if not self.app.vna.connected(): if not self.app.vna.connected():
QtWidgets.QMessageBox( QtWidgets.QMessageBox(
QtWidgets.QMessageBox.Information, QtWidgets.QMessageBox.Icon.Information,
"NanoVNA not connected", "NanoVNA not connected",
( (
"Please ensure the NanoVNA is connected before attempting" "Please ensure the NanoVNA is connected before attempting"
@ -744,7 +744,7 @@ class CalibrationWindow(QtWidgets.QWidget):
if self.app.sweep.properties.mode == SweepMode.CONTINOUS: if self.app.sweep.properties.mode == SweepMode.CONTINOUS:
QtWidgets.QMessageBox( QtWidgets.QMessageBox(
QtWidgets.QMessageBox.Information, QtWidgets.QMessageBox.Icon.Information,
"Continuous sweep enabled", "Continuous sweep enabled",
( (
"Please disable continuous sweeping before attempting" "Please disable continuous sweeping before attempting"
@ -755,18 +755,18 @@ class CalibrationWindow(QtWidgets.QWidget):
return return
short_step = QtWidgets.QMessageBox( short_step = QtWidgets.QMessageBox(
QtWidgets.QMessageBox.Information, QtWidgets.QMessageBox.Icon.Information,
"Calibrate short", "Calibrate short",
( (
'Please connect the "short" standard to port 0 of the' 'Please connect the "short" standard to port 0 of the'
" NanoVNA.\n\n" " NanoVNA.\n\n"
"Press Ok when you are ready to continue." "Press Ok when you are ready to continue."
), ),
QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel,
) )
response = short_step.exec() response = short_step.exec()
if response != QtWidgets.QMessageBox.Ok: if response != QtWidgets.QMessageBox.StandardButton.Ok:
self.btn_automatic.setDisabled(False) self.btn_automatic.setDisabled(False)
return return
self.reset() self.reset()
@ -789,7 +789,7 @@ class CalibrationWindow(QtWidgets.QWidget):
self.nextStep = 1 self.nextStep = 1
open_step = QtWidgets.QMessageBox( open_step = QtWidgets.QMessageBox(
QtWidgets.QMessageBox.Information, QtWidgets.QMessageBox.Icon.Information,
"Calibrate open", "Calibrate open",
( (
'Please connect the "open" standard to port 0 of the' 'Please connect the "open" standard to port 0 of the'
@ -798,11 +798,11 @@ class CalibrationWindow(QtWidgets.QWidget):
" cable unconnected if desired.\n\n" " cable unconnected if desired.\n\n"
"Press Ok when you are ready to continue." "Press Ok when you are ready to continue."
), ),
QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel,
) )
response = open_step.exec() response = open_step.exec()
if response != QtWidgets.QMessageBox.Ok: if response != QtWidgets.QMessageBox.StandardButton.Ok:
self.nextStep = -1 self.nextStep = -1
self.btn_automatic.setDisabled(False) self.btn_automatic.setDisabled(False)
self.app.worker.signals.finished.disconnect( self.app.worker.signals.finished.disconnect(
@ -817,18 +817,18 @@ class CalibrationWindow(QtWidgets.QWidget):
self.cal_save("open") self.cal_save("open")
self.nextStep = 2 self.nextStep = 2
load_step = QtWidgets.QMessageBox( load_step = QtWidgets.QMessageBox(
QtWidgets.QMessageBox.Information, QtWidgets.QMessageBox.Icon.Information,
"Calibrate load", "Calibrate load",
( (
'Please connect the "load" standard to port 0 of the' 'Please connect the "load" standard to port 0 of the'
" NanoVNA.\n\n" " NanoVNA.\n\n"
"Press Ok when you are ready to continue." "Press Ok when you are ready to continue."
), ),
QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel,
) )
response = load_step.exec() response = load_step.exec()
if response != QtWidgets.QMessageBox.Ok: if response != QtWidgets.QMessageBox.StandardButton.Ok:
self.btn_automatic.setDisabled(False) self.btn_automatic.setDisabled(False)
self.nextStep = -1 self.nextStep = -1
self.app.worker.signals.finished.disconnect( self.app.worker.signals.finished.disconnect(
@ -843,7 +843,7 @@ class CalibrationWindow(QtWidgets.QWidget):
self.cal_save("load") self.cal_save("load")
self.nextStep = 3 self.nextStep = 3
continue_step = QtWidgets.QMessageBox( continue_step = QtWidgets.QMessageBox(
QtWidgets.QMessageBox.Information, QtWidgets.QMessageBox.Icon.Information,
"1-port calibration complete", "1-port calibration complete",
( (
"The required steps for a 1-port calibration are now" "The required steps for a 1-port calibration are now"
@ -852,13 +852,13 @@ class CalibrationWindow(QtWidgets.QWidget):
' press "Yes". To apply the 1-port calibration and stop,' ' press "Yes". To apply the 1-port calibration and stop,'
' press "Apply"' ' press "Apply"'
), ),
QtWidgets.QMessageBox.Yes QtWidgets.QMessageBox.StandardButton.Yes
| QtWidgets.QMessageBox.Apply | QtWidgets.QMessageBox.StandardButton.Apply
| QtWidgets.QMessageBox.Cancel, | QtWidgets.QMessageBox.StandardButton.Cancel,
) )
response = continue_step.exec() response = continue_step.exec()
if response == QtWidgets.QMessageBox.Apply: if response == QtWidgets.QMessageBox.StandardButton.Apply:
self.calculate() self.calculate()
self.nextStep = -1 self.nextStep = -1
self.app.worker.signals.finished.disconnect( self.app.worker.signals.finished.disconnect(
@ -866,7 +866,7 @@ class CalibrationWindow(QtWidgets.QWidget):
) )
self.btn_automatic.setDisabled(False) self.btn_automatic.setDisabled(False)
return return
if response != QtWidgets.QMessageBox.Yes: if response != QtWidgets.QMessageBox.StandardButton.Yes:
self.btn_automatic.setDisabled(False) self.btn_automatic.setDisabled(False)
self.nextStep = -1 self.nextStep = -1
self.app.worker.signals.finished.disconnect( self.app.worker.signals.finished.disconnect(
@ -875,7 +875,7 @@ class CalibrationWindow(QtWidgets.QWidget):
return return
isolation_step = QtWidgets.QMessageBox( isolation_step = QtWidgets.QMessageBox(
QtWidgets.QMessageBox.Information, QtWidgets.QMessageBox.Icon.Information,
"Calibrate isolation", "Calibrate isolation",
( (
'Please connect the "load" standard to port 1 of the' 'Please connect the "load" standard to port 1 of the'
@ -884,11 +884,11 @@ class CalibrationWindow(QtWidgets.QWidget):
" port 0.\n\n" " port 0.\n\n"
"Press Ok when you are ready to continue." "Press Ok when you are ready to continue."
), ),
QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel,
) )
response = isolation_step.exec() response = isolation_step.exec()
if response != QtWidgets.QMessageBox.Ok: if response != QtWidgets.QMessageBox.StandardButton.Ok:
self.btn_automatic.setDisabled(False) self.btn_automatic.setDisabled(False)
self.nextStep = -1 self.nextStep = -1
self.app.worker.signals.finished.disconnect( self.app.worker.signals.finished.disconnect(
@ -903,18 +903,18 @@ class CalibrationWindow(QtWidgets.QWidget):
self.cal_save("isolation") self.cal_save("isolation")
self.nextStep = 4 self.nextStep = 4
through_step = QtWidgets.QMessageBox( through_step = QtWidgets.QMessageBox(
QtWidgets.QMessageBox.Information, QtWidgets.QMessageBox.Icon.Information,
"Calibrate through", "Calibrate through",
( (
'Please connect the "through" standard between' 'Please connect the "through" standard between'
" port 0 and port 1 of the NanoVNA.\n\n" " port 0 and port 1 of the NanoVNA.\n\n"
"Press Ok when you are ready to continue." "Press Ok when you are ready to continue."
), ),
QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel,
) )
response = through_step.exec() response = through_step.exec()
if response != QtWidgets.QMessageBox.Ok: if response != QtWidgets.QMessageBox.StandardButton.Ok:
self.btn_automatic.setDisabled(False) self.btn_automatic.setDisabled(False)
self.nextStep = -1 self.nextStep = -1
self.app.worker.signals.finished.disconnect( self.app.worker.signals.finished.disconnect(
@ -929,17 +929,17 @@ class CalibrationWindow(QtWidgets.QWidget):
self.cal_save("thrurefl") self.cal_save("thrurefl")
self.cal_save("through") self.cal_save("through")
apply_step = QtWidgets.QMessageBox( apply_step = QtWidgets.QMessageBox(
QtWidgets.QMessageBox.Information, QtWidgets.QMessageBox.Icon.Information,
"Calibrate complete", "Calibrate complete",
( (
"The calibration process is now complete. Press" "The calibration process is now complete. Press"
' "Apply" to apply the calibration parameters.' ' "Apply" to apply the calibration parameters.'
), ),
QtWidgets.QMessageBox.Apply | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.StandardButton.Apply | QtWidgets.QMessageBox.StandardButton.Cancel,
) )
response = apply_step.exec() response = apply_step.exec()
if response != QtWidgets.QMessageBox.Apply: if response != QtWidgets.QMessageBox.StandardButton.Apply:
self.btn_automatic.setDisabled(False) self.btn_automatic.setDisabled(False)
self.nextStep = -1 self.nextStep = -1
self.app.worker.signals.finished.disconnect( self.app.worker.signals.finished.disconnect(

Wyświetl plik

@ -544,7 +544,7 @@ class DisplaySettingsWindow(QtWidgets.QWidget):
color = getattr(Chart.color, attr) color = getattr(Chart.color, attr)
color = QtWidgets.QColorDialog.getColor( color = QtWidgets.QColorDialog.getColor(
color, options=QtWidgets.QColorDialog.ShowAlphaChannel color, options=QtWidgets.QColorDialog.ColorDialogOption.ShowAlphaChannel
) )
if not color.isValid(): if not color.isValid():
@ -552,7 +552,7 @@ class DisplaySettingsWindow(QtWidgets.QWidget):
return return
palette = sender.palette() palette = sender.palette()
palette.setColor(QPalette.ButtonText, color) palette.setColor(QPalette.ColorRole.ButtonText, color)
sender.setPalette(palette) sender.setPalette(palette)
self.changeSetting(setting, color) self.changeSetting(setting, color)

Wyświetl plik

@ -94,7 +94,7 @@ class FilesWindow(QtWidgets.QWidget):
filedialog.setNameFilter( filedialog.setNameFilter(
"Touchstone 2-Port Files (*.s2p);;All files (*.*)" "Touchstone 2-Port Files (*.s2p);;All files (*.*)"
) )
filedialog.setAcceptMode(QtWidgets.QFileDialog.AcceptSave) filedialog.setAcceptMode(QtWidgets.QFileDialog.AcceptMode.AcceptSave)
selected = filedialog.exec() selected = filedialog.exec()
if not selected: if not selected:
return return