forked from M-Labs/artiq
1
0
Fork 0

gui: fix explicit scan input validation

This commit is contained in:
Sebastien Bourdeauducq 2016-05-30 15:45:28 -05:00
parent 03eeec55b2
commit e6a351c5ea
1 changed files with 3 additions and 2 deletions

View File

@ -212,14 +212,15 @@ class _ExplicitScan(LayoutWidget):
self.addWidget(QtWidgets.QLabel("Sequence:"), 0, 0)
self.addWidget(self.value, 0, 1)
float_regexp = "[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?"
float_regexp = r"(([+-]?\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?)"
regexp = "(float)?( +float)* *".replace("float", float_regexp)
self.value.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(regexp),
self.value))
self.value.setText(" ".join([str(x) for x in state["sequence"]]))
def update(text):
state["sequence"] = [float(x) for x in text.split()]
if self.value.hasAcceptableInput():
state["sequence"] = [float(x) for x in text.split()]
self.value.textEdited.connect(update)