{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# So easy, *voilà*!\n", "\n", "In this example notebook, we demonstrate how Voilà can render Jupyter notebooks with interactions requiring a roundtrip to the kernel." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Jupyter Widgets" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "9d234bc95ca5460ea86e664a957764e3", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(FloatSlider(value=4.0, description='$x$'), FloatText(value=16.0, description='$x^2$', disabled=…" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import ipywidgets as widgets\n", "\n", "slider = widgets.FloatSlider(description='$x$')\n", "text = widgets.FloatText(disabled=True, description='$x^2$')\n", "\n", "def compute(*ignore):\n", " text.value = str(slider.value ** 2)\n", "\n", "slider.observe(compute, 'value')\n", "\n", "slider.value = 4\n", "\n", "widgets.VBox([slider, text])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Basic outputs of code cells" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | sepal_length | \n", "sepal_width | \n", "petal_length | \n", "petal_width | \n", "species | \n", "
---|---|---|---|---|---|
0 | \n", "5.1 | \n", "3.5 | \n", "1.4 | \n", "0.2 | \n", "setosa | \n", "
1 | \n", "4.9 | \n", "3.0 | \n", "1.4 | \n", "0.2 | \n", "setosa | \n", "
2 | \n", "4.7 | \n", "3.2 | \n", "1.3 | \n", "0.2 | \n", "setosa | \n", "
3 | \n", "4.6 | \n", "3.1 | \n", "1.5 | \n", "0.2 | \n", "setosa | \n", "
4 | \n", "5.0 | \n", "3.6 | \n", "1.4 | \n", "0.2 | \n", "setosa | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
145 | \n", "6.7 | \n", "3.0 | \n", "5.2 | \n", "2.3 | \n", "virginica | \n", "
146 | \n", "6.3 | \n", "2.5 | \n", "5.0 | \n", "1.9 | \n", "virginica | \n", "
147 | \n", "6.5 | \n", "3.0 | \n", "5.2 | \n", "2.0 | \n", "virginica | \n", "
148 | \n", "6.2 | \n", "3.4 | \n", "5.4 | \n", "2.3 | \n", "virginica | \n", "
149 | \n", "5.9 | \n", "3.0 | \n", "5.1 | \n", "1.8 | \n", "virginica | \n", "
150 rows × 5 columns
\n", "