From ea2b88afc436d1513c20bb92b4df6e2f618d503f Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Fri, 25 Apr 2014 18:12:49 +0100 Subject: [PATCH] Bugfix to Number widgets. WxPython is annoying. --- fsl/props/widgets.py | 17 +++++++++++------ fsl/tools/bet.py | 6 +++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/fsl/props/widgets.py b/fsl/props/widgets.py index a37ccd7f0..f9b0bdee1 100644 --- a/fsl/props/widgets.py +++ b/fsl/props/widgets.py @@ -290,12 +290,17 @@ def _Number(parent, hasProps, propObj, propVal): maxval = propObj.maxval makeSlider = (minval is not None) and (maxval is not None) + params = {} if isinstance(propObj, props.Int): SpinCtr = wx.SpinCtrl - if minval is None: minval = -sys.maxint - if maxval is None: maxval = sys.maxint - increment = 1 + + # wx.SpinCtrl complains heartily if + # we pass values greater than signed 32 bit + if minval is None: minval = -2 ** 31 + 1 + if maxval is None: maxval = 2 ** 31 - 1 + + value = int(value) elif isinstance(propObj, props.Double): @@ -304,14 +309,14 @@ def _Number(parent, hasProps, propObj, propVal): if maxval is None: maxval = sys.float_info.max if makeSlider: increment = (maxval-minval)/20.0 - else: increment = 0.5 + else: increment = 0.5 + + params['inc'] = increment else: raise TypeError('Unrecognised property type: {}'.format( propObj.__class__.__name__)) - params = {} - params['inc'] = increment params['min'] = minval params['max'] = maxval params['initial'] = value diff --git a/fsl/tools/bet.py b/fsl/tools/bet.py index 299e82535..39dc18f89 100644 --- a/fsl/tools/bet.py +++ b/fsl/tools/bet.py @@ -57,9 +57,9 @@ class Options(props.HasProperties): fractionalIntensity = props.Double(default=0.5, minval=0.0, maxval=1.0) thresholdGradient = props.Double(default=0.0, minval=-1.0, maxval=1.0) headRadius = props.Double(default=0.0, minval=0.0) - xCoordinate = props.Double(default=0.0, minval=0.0) - yCoordinate = props.Double(default=0.0, minval=0.0) - zCoordinate = props.Double(default=0.0, minval=0.0) + xCoordinate = props.Int(default=0, minval=0) + yCoordinate = props.Int(default=0, minval=0) + zCoordinate = props.Int(default=0, minval=0) def setOutputImage(self, value, valid, *a): -- GitLab