check relative path; remove possible cause of #231 #232
@ -78,14 +78,22 @@ class QDSCReader(QtWidgets.QDialog, Ui_Dialog):
|
||||
|
||||
for opts in self.sample.steps:
|
||||
item = QtWidgets.QListWidgetItem()
|
||||
item.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable)
|
||||
item.setCheckState(QtCore.Qt.Unchecked)
|
||||
item.setFlags(
|
||||
QtCore.Qt.ItemFlag.ItemIsEnabled |
|
||||
QtCore.Qt.ItemFlag.ItemIsSelectable |
|
||||
QtCore.Qt.ItemFlag.ItemIsUserCheckable
|
||||
)
|
||||
item.setCheckState(QtCore.Qt.CheckState.Unchecked)
|
||||
|
||||
if opts[0] == 'i':
|
||||
item.setFlags(QtCore.Qt.NoItemFlags)
|
||||
item.setFlags(QtCore.Qt.ItemFlag.NoItemFlags)
|
||||
item.setText(f'{opts[1]:.2f} K for {opts[2] / 60:.0f} min')
|
||||
else:
|
||||
item.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable)
|
||||
item.setFlags(
|
||||
QtCore.Qt.ItemFlag.ItemIsEnabled |
|
||||
QtCore.Qt.ItemFlag.ItemIsSelectable |
|
||||
QtCore.Qt.ItemFlag.ItemIsUserCheckable
|
||||
)
|
||||
item.setText(f'{opts[2]:.2f} K to {opts[3]:.2f} K with {opts[1]} K/min')
|
||||
|
||||
self.step_listWidget.addItem(item)
|
||||
@ -97,7 +105,12 @@ class QDSCReader(QtWidgets.QDialog, Ui_Dialog):
|
||||
|
||||
if empty:
|
||||
self.empty = self.calibrator.set_measurement(empty, mode='empty')
|
||||
self.empty_label.setText('~/' + str(self.empty.fname.relative_to(Path.home())))
|
||||
|
||||
# avoid ValueError breaking data update
|
||||
if self.empty.fname.is_relative_to(Path.home()):
|
||||
self.empty_label.setText('~/' + str(self.empty.fname.relative_to(Path.home())))
|
||||
else:
|
||||
self.empty_label.setText(str(self.empty.fname))
|
||||
|
||||
self.update_plots()
|
||||
|
||||
@ -118,8 +131,8 @@ class QDSCReader(QtWidgets.QDialog, Ui_Dialog):
|
||||
|
||||
self.references.append(ref)
|
||||
item = QtWidgets.QTableWidgetItem(str(ref.fname.name))
|
||||
item.setData(QtCore.Qt.UserRole, ref.fname)
|
||||
item.setFlags(QtCore.Qt.ItemIsEnabled)
|
||||
item.setData(QtCore.Qt.ItemDataRole.UserRole, ref.fname)
|
||||
item.setFlags(QtCore.Qt.ItemFlag.ItemIsEnabled)
|
||||
|
||||
rowcnt = self.reference_tableWidget.rowCount()
|
||||
self.reference_tableWidget.setRowCount(rowcnt+1)
|
||||
@ -132,7 +145,7 @@ class QDSCReader(QtWidgets.QDialog, Ui_Dialog):
|
||||
@QtCore.pyqtSlot(name='on_ref_remove_pushButton_clicked')
|
||||
def remove_reference(self):
|
||||
idx = self.reference_tableWidget.currentRow()
|
||||
self.calibrator.remove_reference(self.reference_tableWidget.item(idx, 0).data(QtCore.Qt.UserRole))
|
||||
self.calibrator.remove_reference(self.reference_tableWidget.item(idx, 0).data(QtCore.Qt.ItemDataRole.UserRole))
|
||||
|
||||
self.reference_tableWidget.removeRow(idx)
|
||||
self.update_plots()
|
||||
@ -145,10 +158,10 @@ class QDSCReader(QtWidgets.QDialog, Ui_Dialog):
|
||||
for row in range(self.step_listWidget.count()):
|
||||
if idx == row:
|
||||
continue
|
||||
self.step_listWidget.item(row).setCheckState(QtCore.Qt.Unchecked)
|
||||
self.step_listWidget.item(row).setCheckState(QtCore.Qt.CheckState.Unchecked)
|
||||
self.step_listWidget.blockSignals(False)
|
||||
|
||||
if item.checkState() == QtCore.Qt.Checked:
|
||||
if item.checkState() == QtCore.Qt.CheckState.Checked:
|
||||
mode, rate, _, _ = self.sample.steps[idx]
|
||||
self.current_run = (rate, mode)
|
||||
self.sample_idx = idx
|
||||
@ -217,6 +230,8 @@ class QDSCReader(QtWidgets.QDialog, Ui_Dialog):
|
||||
|
||||
if empty_data is not None:
|
||||
self.empty_sample.setData(x=empty_data[0], y=empty_data[1])
|
||||
else:
|
||||
self.empty_sample.setData(x=[], y=[])
|
||||
|
||||
self.calib_graph.clear()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user