From d5f2f5c062e77a2f09bb6ab44b2cd4dc9607ba3c Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 25 Aug 2015 00:56:19 +0800 Subject: [PATCH] gui: fix spinbox bounds --- artiq/gui/explorer.py | 8 ++++++-- artiq/gui/scan.py | 18 ++++++++++++------ artiq/gui/tools.py | 8 -------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/artiq/gui/explorer.py b/artiq/gui/explorer.py index c4f5ea680..c8925256b 100644 --- a/artiq/gui/explorer.py +++ b/artiq/gui/explorer.py @@ -6,7 +6,7 @@ from pyqtgraph import LayoutWidget from artiq.protocols.sync_struct import Subscriber from artiq.protocols import pyon -from artiq.gui.tools import DictSyncModel, force_spinbox_value +from artiq.gui.tools import DictSyncModel from artiq.gui.scan import ScanController @@ -79,8 +79,12 @@ class _NumberEntry(QtGui.QDoubleSpinBox): self.setSingleStep(procdesc["step"]) if procdesc["min"] is not None: self.setMinimum(procdesc["min"]) + else: + self.setMinimum(float("-inf")) if procdesc["max"] is not None: self.setMaximum(procdesc["max"]) + else: + self.setMaximum(float("inf")) if procdesc["unit"]: self.setSuffix(" " + procdesc["unit"]) if "default" in procdesc: @@ -90,7 +94,7 @@ class _NumberEntry(QtGui.QDoubleSpinBox): return self.value() def set_argument_value(self, value): - force_spinbox_value(self, value) + self.setValue(value) class _StringEntry(QtGui.QLineEdit): diff --git a/artiq/gui/scan.py b/artiq/gui/scan.py index 65d81ae52..f3405200b 100644 --- a/artiq/gui/scan.py +++ b/artiq/gui/scan.py @@ -1,8 +1,6 @@ from quamash import QtGui from pyqtgraph import LayoutWidget -from artiq.gui.tools import force_spinbox_value - class _Range(LayoutWidget): def __init__(self, global_min, global_max, global_step, unit, ndecimals): @@ -12,8 +10,12 @@ class _Range(LayoutWidget): spinbox.setDecimals(ndecimals) if global_min is not None: spinbox.setMinimum(global_min) + else: + spinbox.setMinimum(float("-inf")) if global_max is not None: spinbox.setMaximum(global_max) + else: + spinbox.setMaximum(float("inf")) if global_step is not None: spinbox.setSingleStep(global_step) if unit: @@ -36,9 +38,9 @@ class _Range(LayoutWidget): self.addWidget(self.npoints, 0, 5) def set_values(self, min, max, npoints): - force_spinbox_value(self.min, min) - force_spinbox_value(self.max, max) - force_spinbox_value(self.npoints, npoints) + self.min.setValue(min) + self.max.setValue(max) + self.npoints.setValue(npoints) def get_values(self): min = self.min.value() @@ -68,8 +70,12 @@ class ScanController(LayoutWidget): self.v_noscan.setDecimals(ndecimals) if gmin is not None: self.v_noscan.setMinimum(gmin) + else: + self.v_noscan.setMinimum(float("-inf")) if gmax is not None: self.v_noscan.setMaximum(gmax) + else: + self.v_noscan.setMaximum(float("inf")) if gstep is not None: self.v_noscan.setSingleStep(gstep) if unit: @@ -135,7 +141,7 @@ class ScanController(LayoutWidget): def set_argument_value(self, d): if d["ty"] == "NoScan": self.noscan.setChecked(True) - force_spinbox_value(self.v_noscan, d["value"]) + self.v_noscan.setValue(d["value"]) elif d["ty"] == "LinearScan": self.linear.setChecked(True) self.v_linear.set_values(d["min"], d["max"], d["npoints"]) diff --git a/artiq/gui/tools.py b/artiq/gui/tools.py index 04476b25d..ecce285ed 100644 --- a/artiq/gui/tools.py +++ b/artiq/gui/tools.py @@ -37,14 +37,6 @@ def short_format(v): return r -def force_spinbox_value(spinbox, value): - if spinbox.minimum() > value: - spinbox.setMinimum(value) - if spinbox.maximum() < value: - spinbox.setMaximum(value) - spinbox.setValue(value) - - class _SyncSubstruct: def __init__(self, update_cb, ref): self.update_cb = update_cb