snuffler: fix errors introduced in 9e381cd82a

gf3d
Sebastian Heimann 2 years ago
parent ffc4428ac5
commit 83b1aa66c1

@ -77,7 +77,8 @@ class Param(object):
low_is_none=None,
high_is_none=None,
low_is_zero=False,
tracking=True):
tracking=True,
type=float):
if low_is_none and default == minimum:
default = None
@ -93,8 +94,8 @@ class Param(object):
self.high_is_none = high_is_none
self.low_is_zero = low_is_zero
self.tracking = tracking
self.type = type
self.type = type(default)
self._control = None
@ -299,7 +300,7 @@ class Snuffling(object):
'--' + param.ident,
dest=param.ident,
default=param.default,
type='float',
type={float: 'float', int: 'int'}[param.type],
help=param.name)
def setup_cli(self):
@ -1214,12 +1215,14 @@ class Snuffling(object):
if param.minimum <= 0.0:
param_control = LinValControl(
high_is_none=param.high_is_none,
low_is_none=param.low_is_none)
low_is_none=param.low_is_none,
type=param.type)
else:
param_control = ValControl(
high_is_none=param.high_is_none,
low_is_none=param.low_is_none,
low_is_zero=param.low_is_zero)
low_is_zero=param.low_is_zero,
type=param.type)
param_control.setup(
param.name,
@ -1229,7 +1232,6 @@ class Snuffling(object):
iparam)
param_control.set_tracking(param.tracking)
param_control.set_type(param.type)
param_control.valchange.connect(
self.modified_snuffling_panel)

@ -248,6 +248,7 @@ class ValControl(qc.QObject):
low_is_none=False,
high_is_none=False,
low_is_zero=False,
type=float,
*args):
qc.QObject.__init__(self, *args)
@ -279,7 +280,7 @@ class ValControl(qc.QObject):
self.lvalue.edited.connect(
self.edited)
self.type = None
self.type = type
self.mute = False
def widgets(self):
@ -291,13 +292,11 @@ class ValControl(qc.QObject):
a = math.log(self.ma/self.mi) / 10000.
value = self.mi*math.exp(a*svalue)
if self.type is not None:
value = self.type(value)
value = self.type(value)
return value
def v2s(self, value):
if self.type is not None:
value = self.type(value)
value = self.type(value)
if value == 0 or self.mi == 0:
return 0
@ -363,9 +362,6 @@ class ValControl(qc.QObject):
def set_tracking(self, tracking):
self.slider.setTracking(tracking)
def set_type(self, value_type):
self.type = value_type
def get_value(self):
return self.cur
@ -417,13 +413,11 @@ class LinValControl(ValControl):
def s2v(self, svalue):
value = svalue/10000. * (self.ma-self.mi) + self.mi
if self.type is not None:
value = self.type(value)
value = self.type(value)
return value
def v2s(self, value):
if self.type is not None:
value = self.type(value)
value = self.type(value)
if self.ma == self.mi:
return 0
return int(round((value-self.mi)/(self.ma-self.mi) * 10000.))

Loading…
Cancel
Save