Skip to content

Fix figure not properly closed in CodeExercise with parameters #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/scwidgets/exercise/_widget_code_exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,6 @@ def __init__(
self._code = code
self._output = CueOutput()

self._parameter_panel: Union[ParameterPanel, None]
if isinstance(params, dict):
self._parameter_panel = ParameterPanel(**params)
elif isinstance(params, ParameterPanel):
self._parameter_panel = params
else:
self._parameter_panel = None

self._cue_code = self._code

if outputs is None:
outputs = []
elif not (isinstance(outputs, list)):
Expand All @@ -205,12 +195,25 @@ def __init__(
self._cue_outputs: List[CueOutput] = []
for output in outputs:
if isinstance(output, Figure):
# This needs to happen before the creation of the
# ParameterPanel otherwise the figure is not properly closed. I
# am not sure why, I guess it is something related to interact
self._cue_outputs.append(CueFigure(output))
elif isinstance(output, CueOutput):
self._cue_outputs.append(output)
else:
self._cue_outputs.append(CueObject(output))

self._parameter_panel: Union[ParameterPanel, None]
if isinstance(params, dict):
self._parameter_panel = ParameterPanel(**params)
elif isinstance(params, ParameterPanel):
self._parameter_panel = params
else:
self._parameter_panel = None

self._cue_code = self._code

if self._check_registry is None or self._code is None:
self._check_button = None
else:
Expand Down
Loading