Skip to content

Commit bfbaa26

Browse files
committed
set_value now returns the new value
this may be different than the value provided, which is now described in the docstring
1 parent 0efc38a commit bfbaa26

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

puzzlepiece/param.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,17 @@ def set_value(self, value=None):
103103
"""
104104
Set the value of the param. If a setter is registered, it will be called.
105105
106-
If the setter returns a value, it will become the new value of this param.
106+
If the setter returns a value, this will become the new value of this param.
107+
108+
If the setter doesn't return a value, the getter will be called if present,
109+
and the value it returns will become the new value of this param.
110+
111+
If the setter doesn't return a value, and there is no getter, the value
112+
provided as an argument will become the new value of this param
107113
108114
:param value: The value this param should be set to (if None, we grab the value from
109115
the param's input box.)
116+
:returns: The new value of the param.
110117
"""
111118
# If a value is not provided, grab one from the input
112119
if value is None:
@@ -128,13 +135,15 @@ def set_value(self, value=None):
128135
new_value = value
129136
# Update the value stored to the new value
130137
self._value = new_value
131-
# Update the input as well, clearing the highlight
138+
# Update the input as well
132139
self._input_set_value(new_value)
133140
else:
134141
self._value = value
135142

143+
# Clear the highlight and emit the changed signal
136144
self.input.setStyleSheet("")
137145
self.changed.emit()
146+
return self._value
138147

139148
def get_value(self):
140149
"""

0 commit comments

Comments
 (0)