Skip to content

Commit

Permalink
[processing] handle ints and floats in range parameter panel
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Nov 17, 2014
1 parent 42f16ef commit 05830c2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
8 changes: 8 additions & 0 deletions python/plugins/processing/core/parameters.py
Expand Up @@ -415,6 +415,14 @@ def __init__(self, name='', description='', default='0,1'):
self.default = default
self.value = None

values = default.split(',')
try:
minVal = int(values[0])
maxVal = int(values[1])
self.isInteger = True
except:
self.isInteger = False

def setValue(self, text):
if text is None:
self.value = self.default
Expand Down
17 changes: 15 additions & 2 deletions python/plugins/processing/gui/RangePanel.py
Expand Up @@ -36,9 +36,22 @@ def __init__(self, param):
QWidget.__init__(self)
self.setupUi(self)

self.isInteger = param.isInteger
if self.isInteger:
self.spnMin.setDecimals(0)
self.spnMax.setDecimals(0)

values = param.default.split(',')
self.spnMin.setValue(float(values[0]))
self.spnMax.setValue(float(values[1]))
minVal = float(values[0])
maxVal = float(values[1])
self.spnMin.setValue(minVal)
self.spnMax.setValue(maxVal)

self.spnMin.setMaximum(maxVal)
self.spnMin.setMinimum(minVal)

self.spnMax.setMaximum(maxVal)
self.spnMax.setMinimum(minVal)

def getValue(self):
return '{},{}'.format(self.spnMin.value(), self.spnMax.value())

0 comments on commit 05830c2

Please sign in to comment.