forked from M-Labs/artiq
gui: get spinboxes to behave
This commit is contained in:
parent
7d81520827
commit
5b62b2452d
@ -7,7 +7,7 @@ from pyqtgraph import LayoutWidget
|
||||
|
||||
from artiq.protocols.sync_struct import Subscriber
|
||||
from artiq.protocols import pyon
|
||||
from artiq.gui.tools import DictSyncModel
|
||||
from artiq.gui.tools import DictSyncModel, force_spinbox_value
|
||||
from artiq.gui.scan import ScanController
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ class _NumberEntry(QtGui.QDoubleSpinBox):
|
||||
if procdesc["unit"]:
|
||||
self.setSuffix(" " + procdesc["unit"])
|
||||
if "default" in procdesc:
|
||||
self.setValue(procdesc["default"])
|
||||
force_spinbox_value(self, procdesc["default"])
|
||||
|
||||
def get_argument_value(self):
|
||||
return self.value()
|
||||
|
@ -1,6 +1,8 @@
|
||||
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):
|
||||
@ -33,9 +35,9 @@ class _Range(LayoutWidget):
|
||||
self.addWidget(self.npoints, 0, 5)
|
||||
|
||||
def set_values(self, min, max, npoints):
|
||||
self.min.setValue(min)
|
||||
self.max.setValue(max)
|
||||
self.npoints.setValue(npoints)
|
||||
force_spinbox_value(self.min, min)
|
||||
force_spinbox_value(self.max, max)
|
||||
force_spinbox_value(self.npoints, npoints)
|
||||
|
||||
def get_values(self):
|
||||
return {
|
||||
@ -97,7 +99,7 @@ class ScanController(LayoutWidget):
|
||||
d = procdesc["default"]
|
||||
if d["ty"] == "NoScan":
|
||||
self.noscan.setChecked(True)
|
||||
self.v_noscan.setValue(d["value"])
|
||||
force_spinbox_value(self.v_noscan, d["value"])
|
||||
elif d["ty"] == "LinearScan":
|
||||
self.linear.setChecked(True)
|
||||
self.v_linear.set_values(d["min"], d["max"], d["step"])
|
||||
|
@ -1,6 +1,14 @@
|
||||
from quamash import QtCore
|
||||
|
||||
|
||||
def force_spinbox_value(spinbox, value):
|
||||
if spinbox.minimum() > value:
|
||||
spinbox.setMinimum(value)
|
||||
if spinbox.maximum() < value:
|
||||
spinbox.setMaximum(value)
|
||||
spinbox.setValue(value)
|
||||
|
||||
|
||||
def short_format(v):
|
||||
t = type(v)
|
||||
if t is int or t is float:
|
||||
|
Loading…
Reference in New Issue
Block a user