def __init__(self, parent=None): """Creates a new instance. :param parent the parent widget """ super().__init__(parent) # Generate controls self.main_layout = QtWidgets.QHBoxLayout(self) self.label = QtWidgets.QLabel("Control Point") self.x_label = QtWidgets.QLabel("X") self.y_label = QtWidgets.QLabel("Y") self.x_input = DynamicDoubleSpinBox() self.x_input.setRange(-1, 1) self.x_input.setDecimals(3) self.x_input.setSingleStep(0.1) self.y_input = DynamicDoubleSpinBox() self.y_input.setRange(-1, 1) self.y_input.setSingleStep(0.1) self.y_input.setDecimals(3) self.main_layout.addWidget(self.label) self.main_layout.addWidget(self.x_label) self.main_layout.addWidget(self.x_input) self.main_layout.addWidget(self.y_label) self.main_layout.addWidget(self.y_input)
def __init__(self, profile_data, parent=None): """Creates a new instance. :param profile_data the data of this response curve :param parent the parent widget """ super().__init__(parent) self.profile_data = profile_data self.main_layout = QtWidgets.QGridLayout(self) # Create the two sliders self.left_slider = DualSlider() self.left_slider.setRange(-100, 0) self.right_slider = DualSlider() self.right_slider.setRange(0, 100) # Create spin boxes for the left slider self.left_lower = DynamicDoubleSpinBox() self.left_lower.setMinimum(-1.0) self.left_lower.setMaximum(0.0) self.left_lower.setSingleStep(0.05) self.left_upper = DynamicDoubleSpinBox() self.left_upper.setMinimum(-1.0) self.left_upper.setMaximum(0.0) self.left_upper.setSingleStep(0.05) # Create spin boxes for the right slider self.right_lower = DynamicDoubleSpinBox() self.right_lower.setSingleStep(0.05) self.right_lower.setMinimum(0.0) self.right_lower.setMaximum(1.0) self.right_upper = DynamicDoubleSpinBox() self.right_upper.setSingleStep(0.05) self.right_upper.setMinimum(0.0) self.right_upper.setMaximum(1.0) self._normalizer =\ self.left_slider.range()[1] - self.left_slider.range()[0] # Hook up all the required callbacks self.left_slider.valueChanged.connect(self._update_left) self.right_slider.valueChanged.connect(self._update_right) self.left_lower.valueChanged.connect( lambda value: self._update_from_spinner( value, DualSlider.LowerHandle, self.left_slider)) self.left_upper.valueChanged.connect( lambda value: self._update_from_spinner( value, DualSlider.UpperHandle, self.left_slider)) self.right_lower.valueChanged.connect( lambda value: self._update_from_spinner( value, DualSlider.LowerHandle, self.right_slider)) self.right_upper.valueChanged.connect( lambda value: self._update_from_spinner( value, DualSlider.UpperHandle, self.right_slider)) # Set slider positions self.set_values(self.profile_data.deadzone) # Put everything into the layout self.main_layout.addWidget(self.left_slider, 0, 0, 1, 2) self.main_layout.addWidget(self.right_slider, 0, 2, 1, 2) self.main_layout.addWidget(self.left_lower, 1, 0) self.main_layout.addWidget(self.left_upper, 1, 1) self.main_layout.addWidget(self.right_lower, 1, 2) self.main_layout.addWidget(self.right_upper, 1, 3)