def __init__(self, procdesc, state): LayoutWidget.__init__(self) scale = procdesc["scale"] self.value = QtWidgets.QDoubleSpinBox() disable_scroll_wheel(self.value) self.value.setDecimals(procdesc["ndecimals"]) if procdesc["global_min"] is not None: self.value.setMinimum(procdesc["global_min"]/scale) else: self.value.setMinimum(float("-inf")) if procdesc["global_max"] is not None: self.value.setMaximum(procdesc["global_max"]/scale) else: self.value.setMaximum(float("inf")) self.value.setSingleStep(procdesc["global_step"]/scale) if procdesc["unit"]: self.value.setSuffix(" " + procdesc["unit"]) self.addWidget(QtWidgets.QLabel("Value:"), 0, 0) self.addWidget(self.value, 0, 1) self.value.setValue(state["value"]/scale) def update(value): state["value"] = value*scale self.value.valueChanged.connect(update)
def __init__(self, argument): ScientificSpinBox.__init__(self) disable_scroll_wheel(self) procdesc = argument["desc"] scale = procdesc["scale"] self.setDecimals(procdesc["ndecimals"]) self.setPrecision() self.setSingleStep(procdesc["step"] / scale) self.setRelativeStep() if procdesc["min"] is not None: self.setMinimum(procdesc["min"] / scale) else: self.setMinimum(float("-inf")) if procdesc["max"] is not None: self.setMaximum(procdesc["max"] / scale) else: self.setMaximum(float("inf")) if procdesc["unit"]: self.setSuffix(" " + procdesc["unit"]) self.setValue(argument["state"] / scale) def update(value): argument["state"] = value * scale self.valueChanged.connect(update)
def __init__(self, argument): ScientificSpinBox.__init__(self) disable_scroll_wheel(self) procdesc = argument["desc"] scale = procdesc["scale"] self.setDecimals(procdesc["ndecimals"]) self.setPrecision() self.setSingleStep(procdesc["step"] / scale) self.setRelativeStep() if procdesc["min"] is not None: self.setMinimum(procdesc["min"] / scale) else: self.setMinimum(float("-inf")) if procdesc["max"] is not None: self.setMaximum(procdesc["max"] / scale) else: self.setMaximum(float("inf")) if procdesc["unit"]: self.setSuffix(" " + procdesc["unit"]) self.setValue(argument["state"] / scale) def update(value): argument["state"] = value * scale self.valueChanged.connect(update)
def __init__(self, argument): QtWidgets.QComboBox.__init__(self) disable_scroll_wheel(self) choices = argument["desc"]["choices"] self.addItems(choices) idx = choices.index(argument["state"]) self.setCurrentIndex(idx) def update(index): argument["state"] = choices[index] self.currentIndexChanged.connect(update)
def __init__(self, argument): QtWidgets.QComboBox.__init__(self) disable_scroll_wheel(self) choices = argument["desc"]["choices"] self.addItems(choices) idx = choices.index(argument["state"]) self.setCurrentIndex(idx) def update(index): argument["state"] = choices[index] self.currentIndexChanged.connect(update)
def __init__(self, procdesc, state): LayoutWidget.__init__(self) scale = procdesc["scale"] self.value = ScientificSpinBox() disable_scroll_wheel(self.value) self.value.setDecimals(procdesc["ndecimals"]) self.value.setPrecision() if procdesc["global_min"] is not None: self.value.setMinimum(procdesc["global_min"] / scale) else: self.value.setMinimum(float("-inf")) if procdesc["global_max"] is not None: self.value.setMaximum(procdesc["global_max"] / scale) else: self.value.setMaximum(float("inf")) self.value.setSingleStep(procdesc["global_step"] / scale) self.value.setRelativeStep() if procdesc["unit"]: self.value.setSuffix(" " + procdesc["unit"]) self.addWidget(QtWidgets.QLabel("Value:"), 0, 0) self.addWidget(self.value, 0, 1) self.value.setValue(state["value"] / scale) def update(value): state["value"] = value * scale self.value.valueChanged.connect(update) self.repetitions = QtWidgets.QSpinBox() self.repetitions.setMinimum(1) self.repetitions.setMaximum((1 << 31) - 1) disable_scroll_wheel(self.repetitions) self.addWidget(QtWidgets.QLabel("Repetitions:"), 1, 0) self.addWidget(self.repetitions, 1, 1) self.repetitions.setValue(state["repetitions"]) def update_repetitions(value): state["repetitions"] = value self.repetitions.valueChanged.connect(update_repetitions)
def __init__(self, procdesc, state): LayoutWidget.__init__(self) scale = procdesc["scale"] self.value = ScientificSpinBox() disable_scroll_wheel(self.value) self.value.setDecimals(procdesc["ndecimals"]) self.value.setPrecision() if procdesc["global_min"] is not None: self.value.setMinimum(procdesc["global_min"] / scale) else: self.value.setMinimum(float("-inf")) if procdesc["global_max"] is not None: self.value.setMaximum(procdesc["global_max"] / scale) else: self.value.setMaximum(float("inf")) self.value.setSingleStep(procdesc["global_step"] / scale) self.value.setRelativeStep() if procdesc["unit"]: self.value.setSuffix(" " + procdesc["unit"]) self.addWidget(QtWidgets.QLabel("Value:"), 0, 0) self.addWidget(self.value, 0, 1) self.value.setValue(state["value"] / scale) def update(value): state["value"] = value * scale self.value.valueChanged.connect(update) self.repetitions = QtWidgets.QSpinBox() self.repetitions.setMinimum(1) self.repetitions.setMaximum((1 << 31) - 1) disable_scroll_wheel(self.repetitions) self.addWidget(QtWidgets.QLabel("Repetitions:"), 1, 0) self.addWidget(self.repetitions, 1, 1) self.repetitions.setValue(state["repetitions"]) def update_repetitions(value): state["repetitions"] = value self.repetitions.valueChanged.connect(update_repetitions)
def __init__(self, argument): QtWidgets.QSpinBox.__init__(self) disable_scroll_wheel(self) procdesc = argument["desc"] self.setSingleStep(procdesc["step"]) if procdesc["min"] is not None: self.setMinimum(procdesc["min"]) else: self.setMinimum(-((1 << 31) - 1)) if procdesc["max"] is not None: self.setMaximum(procdesc["max"]) else: self.setMaximum((1 << 31) - 1) if procdesc["unit"]: self.setSuffix(" " + procdesc["unit"]) self.setValue(argument["state"]) def update(value): argument["state"] = value self.valueChanged.connect(update)
def __init__(self, argument): QtWidgets.QSpinBox.__init__(self) disable_scroll_wheel(self) procdesc = argument["desc"] self.setSingleStep(procdesc["step"]) if procdesc["min"] is not None: self.setMinimum(procdesc["min"]) else: self.setMinimum(-((1 << 31) - 1)) if procdesc["max"] is not None: self.setMaximum(procdesc["max"]) else: self.setMaximum((1 << 31) - 1) if procdesc["unit"]: self.setSuffix(" " + procdesc["unit"]) self.setValue(argument["state"]) def update(value): argument["state"] = value self.valueChanged.connect(update)
def _make_spin_box(self): box = ScientificSpinBox() disable_scroll_wheel(box) box.valueChanged.connect(self.value_changed) spec = self.schema.get("spec", {}) step = spec.get("step", 1.0) box.setDecimals(8) box.setPrecision() box.setSingleStep(step / self.scale) box.setRelativeStep() box.setMinimum(spec.get("min", float("-inf")) / self.scale) box.setMaximum(spec.get("max", float("inf")) / self.scale) unit = spec.get("unit", "") if unit: box.setSuffix(" " + unit) return box
def __init__(self, procdesc, state): LayoutWidget.__init__(self) scale = procdesc["scale"] def apply_properties(spinbox): spinbox.setDecimals(procdesc["ndecimals"]) if procdesc["global_min"] is not None: spinbox.setMinimum(procdesc["global_min"]/scale) else: spinbox.setMinimum(float("-inf")) if procdesc["global_max"] is not None: spinbox.setMaximum(procdesc["global_max"]/scale) else: spinbox.setMaximum(float("inf")) if procdesc["global_step"] is not None: spinbox.setSingleStep(procdesc["global_step"]/scale) if procdesc["unit"]: spinbox.setSuffix(" " + procdesc["unit"]) self.addWidget(QtGui.QLabel("Min:"), 0, 0) self.min = QtGui.QDoubleSpinBox() disable_scroll_wheel(self.min) apply_properties(self.min) self.addWidget(self.min, 0, 1) self.addWidget(QtGui.QLabel("Max:"), 1, 0) self.max = QtGui.QDoubleSpinBox() disable_scroll_wheel(self.max) apply_properties(self.max) self.addWidget(self.max, 1, 1) self.addWidget(QtGui.QLabel("#Points:"), 2, 0) self.npoints = QtGui.QSpinBox() disable_scroll_wheel(self.npoints) self.npoints.setMinimum(2) self.npoints.setValue(10) self.addWidget(self.npoints, 2, 1) self.min.setValue(state["min"]/scale) self.max.setValue(state["max"]/scale) self.npoints.setValue(state["npoints"]) def update_min(value): state["min"] = value*scale def update_max(value): state["min"] = value*scale def update_npoints(value): state["npoints"] = value self.min.valueChanged.connect(update_min) self.max.valueChanged.connect(update_max) self.npoints.valueChanged.connect(update_npoints)
def __init__(self, procdesc, state): LayoutWidget.__init__(self) scale = procdesc["scale"] def apply_properties(widget): widget.setDecimals(procdesc["ndecimals"]) if procdesc["global_min"] is not None: widget.setMinimum(procdesc["global_min"]/scale) else: widget.setMinimum(float("-inf")) if procdesc["global_max"] is not None: widget.setMaximum(procdesc["global_max"]/scale) else: widget.setMaximum(float("inf")) if procdesc["global_step"] is not None: widget.setSingleStep(procdesc["global_step"]/scale) if procdesc["unit"]: widget.setSuffix(" " + procdesc["unit"]) center = ScientificSpinBox() disable_scroll_wheel(center) apply_properties(center) center.setPrecision() center.setRelativeStep() center.setValue(state["center"]/scale) self.addWidget(center, 0, 1) self.addWidget(QtWidgets.QLabel("Center:"), 0, 0) span = ScientificSpinBox() disable_scroll_wheel(span) apply_properties(span) span.setPrecision() span.setRelativeStep() span.setMinimum(0) span.setValue(state["span"]/scale) self.addWidget(span, 1, 1) self.addWidget(QtWidgets.QLabel("Span:"), 1, 0) step = ScientificSpinBox() disable_scroll_wheel(step) apply_properties(step) step.setPrecision() step.setRelativeStep() step.setMinimum(0) step.setValue(state["step"]/scale) self.addWidget(step, 2, 1) self.addWidget(QtWidgets.QLabel("Step:"), 2, 0) randomize = QtWidgets.QCheckBox("Randomize") self.addWidget(randomize, 3, 1) randomize.setChecked(state["randomize"]) def update_center(value): state["center"] = value*scale def update_span(value): state["span"] = value*scale def update_step(value): state["step"] = value*scale def update_randomize(value): state["randomize"] = value center.valueChanged.connect(update_center) span.valueChanged.connect(update_span) step.valueChanged.connect(update_step) randomize.stateChanged.connect(update_randomize)
def __init__(self, procdesc, state): LayoutWidget.__init__(self) scale = procdesc["scale"] def apply_properties(widget): widget.setDecimals(procdesc["ndecimals"]) if procdesc["global_min"] is not None: widget.setMinimum(procdesc["global_min"]/scale) else: widget.setMinimum(float("-inf")) if procdesc["global_max"] is not None: widget.setMaximum(procdesc["global_max"]/scale) else: widget.setMaximum(float("inf")) if procdesc["global_step"] is not None: widget.setSingleStep(procdesc["global_step"]/scale) if procdesc["unit"]: widget.setSuffix(" " + procdesc["unit"]) scanner = ScanWidget() disable_scroll_wheel(scanner) self.addWidget(scanner, 0, 0, -1, 1) start = ScientificSpinBox() start.setStyleSheet("QDoubleSpinBox {color:blue}") start.setMinimumSize(110, 0) start.setSizePolicy(QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)) disable_scroll_wheel(start) self.addWidget(start, 0, 1) npoints = QtWidgets.QSpinBox() npoints.setMinimum(1) npoints.setMaximum((1 << 31) - 1) disable_scroll_wheel(npoints) self.addWidget(npoints, 1, 1) stop = ScientificSpinBox() stop.setStyleSheet("QDoubleSpinBox {color:red}") stop.setMinimumSize(110, 0) disable_scroll_wheel(stop) self.addWidget(stop, 2, 1) randomize = QtWidgets.QCheckBox("Randomize") self.addWidget(randomize, 3, 1) apply_properties(start) start.setPrecision() start.setRelativeStep() apply_properties(stop) stop.setPrecision() stop.setRelativeStep() apply_properties(scanner) def update_start(value): state["start"] = value*scale scanner.setStart(value) if start.value() != value: start.setValue(value) def update_stop(value): state["stop"] = value*scale scanner.setStop(value) if stop.value() != value: stop.setValue(value) def update_npoints(value): state["npoints"] = value scanner.setNum(value) if npoints.value() != value: npoints.setValue(value) def update_randomize(value): state["randomize"] = value randomize.setChecked(value) scanner.startChanged.connect(update_start) scanner.numChanged.connect(update_npoints) scanner.stopChanged.connect(update_stop) start.valueChanged.connect(update_start) npoints.valueChanged.connect(update_npoints) stop.valueChanged.connect(update_stop) randomize.stateChanged.connect(update_randomize) scanner.setStart(state["start"]/scale) scanner.setNum(state["npoints"]) scanner.setStop(state["stop"]/scale) randomize.setChecked(state["randomize"])
def __init__(self, procdesc, state): LayoutWidget.__init__(self) scale = procdesc["scale"] def apply_properties(widget): widget.setDecimals(procdesc["ndecimals"]) if procdesc["global_min"] is not None: widget.setMinimum(procdesc["global_min"]/scale) else: widget.setMinimum(float("-inf")) if procdesc["global_max"] is not None: widget.setMaximum(procdesc["global_max"]/scale) else: widget.setMaximum(float("inf")) if procdesc["global_step"] is not None: widget.setSingleStep(procdesc["global_step"]/scale) if procdesc["unit"]: widget.setSuffix(" " + procdesc["unit"]) scanner = ScanWidget() disable_scroll_wheel(scanner) self.addWidget(scanner, 0, 0, -1, 1) start = ScientificSpinBox() start.setStyleSheet("QDoubleSpinBox {color:blue}") start.setMinimumSize(110, 0) start.setSizePolicy(QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)) disable_scroll_wheel(start) self.addWidget(start, 0, 1) npoints = QtWidgets.QSpinBox() npoints.setMinimum(1) npoints.setMaximum((1 << 31) - 1) disable_scroll_wheel(npoints) self.addWidget(npoints, 1, 1) stop = ScientificSpinBox() stop.setStyleSheet("QDoubleSpinBox {color:red}") stop.setMinimumSize(110, 0) disable_scroll_wheel(stop) self.addWidget(stop, 2, 1) def update_start(value): state["start"] = value*scale scanner.setStart(value) def update_stop(value): state["stop"] = value*scale scanner.setStop(value) def update_npoints(value): state["npoints"] = value scanner.setNum(value) scanner.startChanged.connect(start.setValue) scanner.numChanged.connect(npoints.setValue) scanner.stopChanged.connect(stop.setValue) start.valueChanged.connect(update_start) npoints.valueChanged.connect(update_npoints) stop.valueChanged.connect(update_stop) scanner.setStart(state["start"]/scale) scanner.setNum(state["npoints"]) scanner.setStop(state["stop"]/scale) apply_properties(start) apply_properties(stop) apply_properties(scanner)
def __init__(self, procdesc, state): LayoutWidget.__init__(self) scale = procdesc["scale"] def apply_properties(widget): widget.setDecimals(procdesc["ndecimals"]) if procdesc["global_min"] is not None: widget.setMinimum(procdesc["global_min"]/scale) else: widget.setMinimum(float("-inf")) if procdesc["global_max"] is not None: widget.setMaximum(procdesc["global_max"]/scale) else: widget.setMaximum(float("inf")) if procdesc["global_step"] is not None: widget.setSingleStep(procdesc["global_step"]/scale) if procdesc["unit"]: widget.setSuffix(" " + procdesc["unit"]) center = ScientificSpinBox() disable_scroll_wheel(center) apply_properties(center) center.setPrecision() center.setRelativeStep() center.setValue(state["center"]) self.addWidget(center, 0, 1) self.addWidget(QtWidgets.QLabel("Center:"), 0, 0) span = ScientificSpinBox() disable_scroll_wheel(span) apply_properties(span) span.setPrecision() span.setRelativeStep() span.setMinimum(0) span.setValue(state["span"]) self.addWidget(span, 1, 1) self.addWidget(QtWidgets.QLabel("Span:"), 1, 0) step = ScientificSpinBox() disable_scroll_wheel(step) apply_properties(step) step.setPrecision() step.setRelativeStep() step.setMinimum(0) step.setValue(state["step"]) self.addWidget(step, 2, 1) self.addWidget(QtWidgets.QLabel("Step:"), 2, 0) randomize = QtWidgets.QCheckBox("Randomize") self.addWidget(randomize, 3, 1) randomize.setChecked(state["randomize"]) def update_center(value): state["center"] = value*scale def update_span(value): state["span"] = value*scale def update_step(value): state["step"] = value*scale def update_randomize(value): state["randomize"] = value center.valueChanged.connect(update_center) span.valueChanged.connect(update_span) step.valueChanged.connect(update_step) randomize.stateChanged.connect(update_randomize)