Skip to content

Commit

Permalink
Rename from CueObject the display_object to object (#96)
Browse files Browse the repository at this point in the history
Shortens the name for usage and it is clearer is it is derived from the
name of the class.
  • Loading branch information
agoscinski authored Dec 17, 2024
1 parent 99a24f6 commit 2b367a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions src/scwidgets/cue/_widget_cue_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CueObject(CueOutput):
A cued displayable ipywidget.Output for any Python object. Provides utilities to
clear and redraw the object, for example after an update.
:param display_object:
:param object:
The object to display
:param widgets_to_observe:
The widget to observe if the :param traits_to_observe: has changed.
Expand All @@ -35,7 +35,7 @@ class CueObject(CueOutput):

def __init__(
self,
display_object: Any = None,
object: Any = None,
widgets_to_observe: Union[None, List[Widget], Widget] = None,
traits_to_observe: Union[
None, str, List[str], List[List[str]], Sentinel
Expand All @@ -54,23 +54,23 @@ def __init__(
**kwargs,
)

self._display_object = display_object
self._object = object
self.draw_display()

@property
def display_object(self):
return self._display_object
def object(self):
return self._object

@display_object.setter
def display_object(self, display_object: Any):
self._display_object = display_object
@object.setter
def object(self, object: Any):
self._object = object

def clear_display(self, wait=False):
self.clear_output(wait=wait)

def draw_display(self):
with self:
if isinstance(self._display_object, str):
print(self._display_object)
elif self._display_object is not None:
display(self._display_object)
if isinstance(self._object, str):
print(self._object)
elif self._object is not None:
display(self._object)
6 changes: 3 additions & 3 deletions tests/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def update_print():
output = code_ex.params
else:
output = code_ex.run_code(**code_ex.params)
code_ex.output.display_object = f"Output:\n{output}"
code_ex.output.object = f"Output:\n{output}"

else:

Expand All @@ -198,7 +198,7 @@ def update_print(code_ex: CodeExercise):
output = code_ex.params
else:
output = code_ex.run_code(**code_ex.params)
code_ex.output.display_object = f"Output:\n{output}"
code_ex.output.object = f"Output:\n{output}"

code_ex = CodeExercise(
code=code_input,
Expand Down Expand Up @@ -329,7 +329,7 @@ def test_save_registry(self, function):
"""

def print_success(code_ex: CodeExercise | None):
code_ex.output.display_object = "Success"
code_ex.output.object = "Success"

cue_output = CueObject("Not initialized")
exercise_registry = ExerciseRegistry()
Expand Down

0 comments on commit 2b367a8

Please sign in to comment.