From e6a351c5ea17a3dc2d670828e6a23f979d95407a 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 8dc0a9ea3..2eab00ad6 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)