|
From: cfalcon <cf...@ce...> - 2015-06-29 11:21:01
|
From: srubio <sr...@ce...>
The format is initialized in the init method, so it is not updated once
the gui was launching. Fix it, moving the min. and max. value
calculation ("_setMinMax" method) in the _setDigits method.
---
lib/taurus/qt/qtgui/input/qwheel.py | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/lib/taurus/qt/qtgui/input/qwheel.py b/lib/taurus/qt/qtgui/input/qwheel.py
index 41a6852..e02bdf5 100644
--- a/lib/taurus/qt/qtgui/input/qwheel.py
+++ b/lib/taurus/qt/qtgui/input/qwheel.py
@@ -208,7 +208,6 @@ class QWheelEdit(Qt.QFrame):
self._showArrowButtons = True
self._setDigits(QWheelEdit.DefaultIntDigitCount, QWheelEdit.DefaultDecDigitCount)
- self._setMinMax( self._getMinPossibleValue(), self._getMaxPossibleValue())
self._setValue(0)
self._build()
@@ -253,13 +252,12 @@ class QWheelEdit(Qt.QFrame):
self._upButtons = Qt.QButtonGroup()
self._downButtons = Qt.QButtonGroup()
self._digitLabels = []
- for l in self._digitLabels: l.setAlignment(Qt.AlignCenter)
-
+
showDot = self.getDecDigitCount() > 0
signLabel = _DigitLabel('+')
signLabel.setFocusPolicy(Qt.Qt.NoFocus)
- signLabel.setAlignment(Qt.Qt.AlignRight)
+ signLabel.setAlignment(Qt.Qt.AlignCenter)
self._digitLabels.append(signLabel)
l.addWidget(signLabel, 1, 0)
l.setRowMinimumHeight(1, signLabel.minimumSizeHint().height())
@@ -389,6 +387,8 @@ class QWheelEdit(Qt.QFrame):
if self._decDigitCount > 0:
total_chars += 1 # for dot
self._valueFormat = '%%+0%d.%df' % (total_chars, self._decDigitCount)
+ self._setMinMax( self._getMinPossibleValue(),
+ self._getMaxPossibleValue())
# we call setValue to update the self._value_str
self._setValue(self.getValue())
@@ -403,10 +403,11 @@ class QWheelEdit(Qt.QFrame):
@return (str) a proper string representation of the given value
"""
if v is None:
- return (self._valueFormat % 0).replace('0', '-')
- ret = self._valueFormat % v
- if ret.endswith('nan'):
- ret = ret.replace('0',' ')
+ ret = (self._valueFormat % 0).replace('0', '-')
+ else:
+ ret = self._valueFormat % v
+ if ret.endswith('nan'):
+ ret = ret.replace('0',' ')
self._value_str = ret
return ret
--
2.4.0
|