Skip to content
Snippets Groups Projects
Commit 2f87fc17 authored by Rostislav Chudoba's avatar Rostislav Chudoba
Browse files

adding appmode
parent ccd22d56
No related branches found
No related tags found
No related merge requests found
name: bmcsapps
channels:
- conda-forge
dependencies:
......@@ -6,3 +7,5 @@ dependencies:
- numpy
- sympy
- ipywidgets
- rise
%% Cell type:markdown id: tags:
# Appmode in Jupyter
This page demonstrates how to generate online "apps" with a Jupyter Notebook interface. With the `appmode` plugin, we can create interactive experiences without requiring coding or running a specific cell.
Markdown cells will be retained, and all code cells will be run, then hidden. The outputs of each cell will be displayed as well.
Check out a further example using an [ipyvolume](https://ipyvolume.readthedocs.io/en/latest/) to render a 3D plot: [ipyvolume_demo.ipynb](ipyvolume_demo.ipynb)
%% Cell type:code id: tags:
``` python
from __future__ import division
import ipywidgets as ipw
output = ipw.Text(placeholder="0", layout=ipw.Layout(width="190px"), disabled=True)
def on_click(btn):
if btn.description == "=":
try:
output.value = str(eval(output.value))
except:
output.value = "ERROR"
elif btn.description == "AC":
output.value = ""
elif btn.description == "del":
output.value = output.value[:-1]
else:
output.value = output.value + btn.description
def mk_btn(description):
btn = ipw.Button(description=description, layout=ipw.Layout(width="45px"))
btn.on_click(on_click)
return btn
row0 = ipw.HBox([mk_btn(d) for d in ("(", ")", "del", "AC")])
row1 = ipw.HBox([mk_btn(d) for d in ("7", "8", "9", " / ")])
row2 = ipw.HBox([mk_btn(d) for d in ("4", "5", "6", " * ")])
row3 = ipw.HBox([mk_btn(d) for d in ("1", "2", "3", " - ")])
row4 = ipw.HBox([mk_btn(d) for d in ("0", ".", "=", " + ")])
ipw.VBox((output, row0, row1, row2, row3, row4))
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment