def _setup(self, tree, parameter, name): super()._setup(tree, name) self.alias_label = CenteredLabel() self.result = CenteredLabel('') self.stderr = CenteredLabel('') tree.setItemWidget(self, 2, self.alias_label) tree.setItemWidget(self, 3, self.result) tree.setItemWidget(self, 4, self.stderr) self.update_result(parameter)
def _setup(self, orbital, orientation): self.button = QPushButton('X') self.ID_label = CenteredLabel('%i' % orbital.ID) self.name_label = CenteredLabel(orbital.name) self.weight = WeightSpinBox() phi, theta, psi = orientation_to_euler_angle(orientation) self.phi = AngleSpinBox(phi, 'phi') self.theta = AngleSpinBox(theta, 'theta') self.psi = AngleSpinBox(psi, 'psi') self.use = UseCheckBox() self.name_label.setToolTip(str(orbital))
def _setup(self, tree, orbital, result): super()._setup(tree, orbital.name) self.name_label.setToolTip(str(orbital)) self.ID = orbital.ID self.ID_label = CenteredLabel('%i' % self.ID) tree.setItemWidget(self, 0, self.ID_label) weight = DataResultTreeItem(self, tree, result['w_' + str(self.ID)], 'Weight', units='', decimals=2) phi = DataResultTreeItem(self, tree, result['phi_' + str(self.ID)], 'Phi', units='°', decimals=3) theta = DataResultTreeItem(self, tree, result['theta_' + str(self.ID)], 'Theta', units='°', decimals=3) psi = DataResultTreeItem(self, tree, result['psi_' + str(self.ID)], 'Psi', units='°', decimals=3) self.parameters = [ variable + '_' + str(self.ID) for variable in ['w', 'phi', 'theta', 'psi']] self.children = [weight, phi, theta, psi]
def _setup(self, tree, name): self.name_label = CenteredLabel(name) self.vary = QCheckBox() layout = QHBoxLayout() layout.addWidget(self.vary) layout.setAlignment(Qt.AlignCenter) layout.setContentsMargins(0, 0, 0, 0) center_widget = QWidget() center_widget.setLayout(layout) tree.setItemWidget(self, 1, self.name_label) tree.setItemWidget(self, 3, center_widget)
def _setup(self, tree, name): name = self.parameter.name if name is None else name super()._setup(tree, name) self.alias_label = CenteredLabel(self.parameter.name) expression = '' if self.parameter.expr is None else self.parameter.expr self.expression = QLineEdit(expression) tree.setItemWidget(self, 2, self.alias_label) tree.setItemWidget(self, 4, self.initial_spinbox) tree.setItemWidget(self, 5, self.min_spinbox) tree.setItemWidget(self, 6, self.max_spinbox) tree.setItemWidget(self, 7, self.expression)
def _setup(self, tree, orbital, parameters): super()._setup(tree, orbital.name) self.ID_label = CenteredLabel('%i' % self.ID) self.name_label.setToolTip(str(orbital)) tree.setItemWidget(self, 0, self.ID_label) weight = WeightTreeItem(self, tree, parameters['w_' + str(self.ID)], 'Weight') phi = AngleTreeItem(self, tree, parameters['phi_' + str(self.ID)], 'Phi') theta = AngleTreeItem(self, tree, parameters['theta_' + str(self.ID)], 'Theta') psi = AngleTreeItem(self, tree, parameters['psi_' + str(self.ID)], 'Psi') self.children = [weight, phi, theta, psi]
def _setup(self, tree, name): self.name_label = CenteredLabel(name) tree.setItemWidget(self, 1, self.name_label)
class OrbitalTableRow(QWidget): row_removed = pyqtSignal(int) parameter_changed = pyqtSignal(int, str, float) use_changed = pyqtSignal(int) def __init__(self, orbital, orientation, *args, **kwargs): self.ID = orbital.ID super(OrbitalTableRow, self).__init__(*args, **kwargs) self._setup(orbital, orientation) self._connect() def remove_row(self): self.row_removed.emit(self.ID) def get_parameters(self): weight = self.weight.value() phi = self.phi.value() theta = self.theta.value() psi = self.psi.value() return weight, phi, theta, psi def get_use(self): return self.use.isChecked() def change_parameter(self): sender = self.sender() parameter = sender.objectName() value = sender.value() self.parameter_changed.emit(self.ID, parameter, value) def change_use(self): self.use_changed.emit(self.ID) def update_use(self, state): self.use.setChecked(state) self.change_use() def update_parameter_silently(self, parameter, value): widgets = [self.weight, self.phi, self.theta, self.psi] for widget in widgets: if widget.objectName() == parameter: widget.blockSignals(True) widget.setValue(value) widget.blockSignals(False) def _setup(self, orbital, orientation): self.button = QPushButton('X') self.ID_label = CenteredLabel('%i' % orbital.ID) self.name_label = CenteredLabel(orbital.name) self.weight = WeightSpinBox() phi, theta, psi = orientation_to_euler_angle(orientation) self.phi = AngleSpinBox(phi, 'phi') self.theta = AngleSpinBox(theta, 'theta') self.psi = AngleSpinBox(psi, 'psi') self.use = UseCheckBox() self.name_label.setToolTip(str(orbital)) def _connect(self): self.button.clicked.connect(self.remove_row) self.weight.valueChanged.connect(self.change_parameter) self.phi.valueChanged.connect(self.change_parameter) self.theta.valueChanged.connect(self.change_parameter) self.psi.valueChanged.connect(self.change_parameter) self.use.stateChanged.connect(self.change_use)