Skip to content

Commit

Permalink
set_value now returns the new value
Browse files Browse the repository at this point in the history
this may be different than the value provided, which is now described in the docstring
  • Loading branch information
jdranczewski committed Dec 8, 2023
1 parent 0efc38a commit bfbaa26
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions puzzlepiece/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,17 @@ def set_value(self, value=None):
"""
Set the value of the param. If a setter is registered, it will be called.
If the setter returns a value, it will become the new value of this param.
If the setter returns a value, this will become the new value of this param.
If the setter doesn't return a value, the getter will be called if present,
and the value it returns will become the new value of this param.
If the setter doesn't return a value, and there is no getter, the value
provided as an argument will become the new value of this param
:param value: The value this param should be set to (if None, we grab the value from
the param's input box.)
:returns: The new value of the param.
"""
# If a value is not provided, grab one from the input
if value is None:
Expand All @@ -128,13 +135,15 @@ def set_value(self, value=None):
new_value = value
# Update the value stored to the new value
self._value = new_value
# Update the input as well, clearing the highlight
# Update the input as well
self._input_set_value(new_value)
else:
self._value = value

# Clear the highlight and emit the changed signal
self.input.setStyleSheet("")
self.changed.emit()
return self._value

def get_value(self):
"""
Expand Down

0 comments on commit bfbaa26

Please sign in to comment.