Usage¶
Using illusionist is very easy. You don't need to change anything on you current Jupyter Notebook or import any Python libraries to generate a report.
Let's create a very simple notebook that does a multiplication operation using Widgets
import ipywidgets as widgets
slider = widgets.IntSlider(description="Number", max=10, value=5)
slider
bounded_int = widgets.BoundedIntText(description="Multiplier", value=2, min=0, max=5)
bounded_int
multiplication = widgets.Label()
multiplication
def update_lbl(args):
multiplication.value = str(slider.value * bounded_int.value)
update_lbl(None)
slider.observe(update_lbl, 'value')
bounded_int.observe(update_lbl, 'value')
Info
Note that the widgets in this docs page are not (yet) using illusionist. So the values will not be updated. Keep reading to see working examples.
Generating the report¶
Now that we have a working set of Jupyter Widgets working we can convert it to an HTML file using nbconvert
just add the --to illusionist
argument.
jupyter nbconvert --to illusionist multiplier.ipynb
This will generate: multiplier.html (open this file to see the final output).
You can also add the illusionist metadata to an .ipynb
file.
jupyter nbconvert --to illusionist-nb --execute multiplier.ipynb --output=multiplier-output.ipynb
You can then use nbviewer.js to see it in a directly browser without converting it to an HTML file. See multiplier-output.ipynb.
Output Widgets¶
You are not limited to using control Jupyter Widgets you can also use Output Widgets to for example show plots and other interactive components.
See matplotlib.ipynb.