From f53756276811219dc60dc02b3061006e75199322 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 30 May 2016 15:45:28 -0500 Subject: [PATCH] gui: fix explicit scan input validation --- artiq/gui/entries.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/artiq/gui/entries.py b/artiq/gui/entries.py index 70b1026a6..575f2de3d 100644 --- a/artiq/gui/entries.py +++ b/artiq/gui/entries.py @@ -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)