From a48a3776be264b39b723bae1e7c4f47669f3135b Mon Sep 17 00:00:00 2001 From: Pol Welter Date: Fri, 1 Jun 2018 10:31:47 +0200 Subject: [PATCH] Fix issue #697 --- pyqtgraph/widgets/SpinBox.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pyqtgraph/widgets/SpinBox.py b/pyqtgraph/widgets/SpinBox.py index ea59bf31..496ea37a 100644 --- a/pyqtgraph/widgets/SpinBox.py +++ b/pyqtgraph/widgets/SpinBox.py @@ -509,8 +509,14 @@ class SpinBox(QtGui.QAbstractSpinBox): def fixup(self, strn): # fixup is called when the spinbox loses focus with an invalid or intermediate string self.updateText() - strn.clear() - strn.append(self.lineEdit().text()) + + # support both PyQt APIs (for Python 2 and 3 respectively) + # http://pyqt.sourceforge.net/Docs/PyQt4/python_v3.html#qvalidator + try: + strn.clear() + strn.append(self.lineEdit().text()) + except AttributeError: + return self.lineEdit().text() def interpret(self): """Return value of text or False if text is invalid."""