my ipywidgets work in jupyter notebook, but not in html file after exporting

Question:

i can press a button and get it to trigger events within the notebook, but when i export a html file, they no longer work.

import ipywidgets as widgets
from IPython.display import HTML
from ipywidgets import interactive
from ipywidgets import interact
from ipywidgets.embed import embed_minimal_html
from IPython.display import display
output = widgets.Output()

submitButton = widgets.Button(
  description='Click me',
  disabled=False,
  button_style='', # 'success', 'info', 'warning', 'danger' or ''
  tooltip='Click me',
  icon='check' # (FontAwesome names without the `fa-` prefix)
)

def buttonClick(btn):
  with output:
    print("Button clicked.")
  display(output)
  return True

submitButton.on_click(buttonClick)

def f(x):
  return x

display(submitButton)
submitButton.observe(buttonClick, names='value')
embed_minimal_html('export1.html', views=[submitButton, output], title='Widgets export')

I have tried using interact, interactive, and output; but can’t get it to work.
The html file should show the button and when clicked should say "Button clicked."
The button shows but the text doesn’t appear.

Asked By: cameronmg-j

||

Answers:

(see wayne’s comment for more info) import solara and it should allow you to use ipywidgets and more in a separate web page.

Answered By: cameronmg-j