From 6059ae268695bbef10b96dd973a0cce7531ad39b Mon Sep 17 00:00:00 2001 From: Michele Ceriotti Date: Sun, 27 Aug 2023 17:41:34 -0700 Subject: [PATCH] Fixed the settings logic so chemiscope.save behaves well also without displaying first --- python/chemiscope/jupyter.py | 3 ++- python/jupyter/src/widget.css | 2 +- python/jupyter/src/widget.ts | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/chemiscope/jupyter.py b/python/chemiscope/jupyter.py index 181920f33..40035d733 100644 --- a/python/chemiscope/jupyter.py +++ b/python/chemiscope/jupyter.py @@ -30,9 +30,10 @@ class ChemiscopeWidgetBase(ipywidgets.DOMWidget, ipywidgets.ValueWidget): def __init__(self, data, has_metadata): super().__init__() + self.value = json.dumps(data) self.has_metadata = has_metadata - self.settings = {} + self.settings = data["settings"] self._settings_sync = True def save(self, path): diff --git a/python/jupyter/src/widget.css b/python/jupyter/src/widget.css index 322b566b7..44a9c2036 100644 --- a/python/jupyter/src/widget.css +++ b/python/jupyter/src/widget.css @@ -85,6 +85,6 @@ html { /* hide the slider when showing the map only (no need for navigation) uses part() to access styling within the shadow DOM */ -.chemiscope-meta-and-map .chemiscope-info *::part(chsp-slider) { +.chemiscope-meta-and-map .chemiscope-info *::part(chsp-slider) { display: none; } diff --git a/python/jupyter/src/widget.ts b/python/jupyter/src/widget.ts index e9ba1a6ef..128a4c9ca 100644 --- a/python/jupyter/src/widget.ts +++ b/python/jupyter/src/widget.ts @@ -48,7 +48,6 @@ class ChemiscopeBaseView extends DOMWidgetView { }, this ); - this._updatePythonSettings(); } protected _updatePythonSettings(): void {