Skip to content

Commit

Permalink
gui: fix explicit scan input validation
Browse files Browse the repository at this point in the history
sbourdeauducq committed May 30, 2016
1 parent 03eeec5 commit e6a351c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions artiq/gui/entries.py
Original file line number Diff line number Diff line change
@@ -212,14 +212,15 @@ def __init__(self, state):
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)


0 comments on commit e6a351c

Please sign in to comment.