ipywidgets icon indicating copy to clipboard operation
ipywidgets copied to clipboard

widgets.HTML (and HBox) do not save output after page reload or ipynb file re-open

Open liudmylaru opened this issue 3 years ago • 2 comments
trafficstars

Description

I run widgets.HTML in Jupyter notebook (file.ipynb) and output looks fancy. When I reload page or when I close/re-open Jupyter notebook fancy output not saved, but HTML(value=... ) shown in output cell instead of expected text.

Reproduce

  1. create ipynb file with this code in cell: import ipywidgets as widgets widgets.HTML(value="Hello World")
  2. run ipynb file and expect to see fancy (formatted) test output
  3. save ipynb file
  4. close ipynb file
  5. open ipynb file
  6. I see in the output instead of fancy text: "HTML(value='Hello World')"
  7. to get again fancy output I need to run the cell again. I need to have outputs in all (and in HTML widgets outputs also) cells after file re-opened, because some cells in same ipynb can take hours to run. It also seen in HBox widgets (output not saved and after re-open). I did not check in other widgets.

Expected behavior

When close and re-open notebook, cells outputs has to be the same before I closed notebook (file.ipynb).

Context

  • ipywidgets version 7.6.3
  • Operating System and version: Linux
  • Browser and version: Chrome, Version 96.0.4664.110

If using JupyterLab

  • JupyterLab version: Version 2.2.6

jupyter labextension list JupyterLab v2.2.6 Known labextensions: app dir: /opt/conda/share/jupyter/lab @bokeh/jupyter_bokeh v2.0.4 enabled OK @jupyter-widgets/jupyterlab-manager v2.0.0 enabled OK @jupyterlab/cellone-extension v0.1.4 enabled OK @jupyterlab/explorer-extension v0.2.18 enabled OK @jupyterlab/fasta-extension v2.0.0 enabled OK @jupyterlab/geojson-extension v2.0.1 enabled OK @jupyterlab/git v0.24.0 enabled OK @jupyterlab/katex-extension v2.0.0 enabled OK @jupyterlab/mathjax2-extension v2.2.4 enabled OK @jupyterlab/mathjax3-extension v3.0.0 enabled OK @jupyterlab/oracle-splash-screen v0.1.0 enabled OK @jupyterlab/templates-extension v0.2.5 enabled OK @jupyterlab/toc v4.0.0 enabled OK @jupyterlab/vega5-extension v2.2.0 enabled OK @lckr/jupyterlab_variableinspector v0.5.1 enabled OK jupyter-leaflet v0.13.0 enabled OK jupyterlab-plotly v4.8.2 enabled OK nbdime-jupyterlab v2.0.2 enabled OK plotlywidget v4.8.2 enabled OK

liudmylaru avatar Dec 22 '21 20:12 liudmylaru

I think you might need to check the "Save Widget State" or similar option in the menu in Lab.

vidartf avatar Jan 10 '22 10:01 vidartf

hi! I used this menu as you suggested. In Jupyterlab it is "Settings -> Save Widget State Automatically". Result the same. when reload page or re-open Jupytelab notebook result not persist.

  1. Check menu item to Save widget sate: image
  2. run code: image
  3. reload page (or re-open Jupyterlab notebook): image

Fancy formatting not persist in output cell.

liudmylaru avatar Jan 13 '22 18:01 liudmylaru