wut-web-dev cruft input tests wtf
parent
5484aa9ad3
commit
6c1a569246
|
@ -33,23 +33,42 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# cell 1\n",
|
||||
"from ipywidgets import *\n",
|
||||
"import time\n",
|
||||
"\n",
|
||||
"slider = IntSlider(\n",
|
||||
" value=7,\n",
|
||||
" min=1,\n",
|
||||
" max=10.0,\n",
|
||||
" step=1,\n",
|
||||
" description=\"Input:\",\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"display(slider)\n",
|
||||
"time.sleep(10) # move slider to 5"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print(\"done \" + str(slider.value))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"### cell #1\n",
|
||||
"#import ipywidgets as widgets\n",
|
||||
"#import ipython_blocking\n",
|
||||
"#import ipython_blocking # enables %block and %blockrun magic\n",
|
||||
"\n",
|
||||
"#text = widgets.Text()\n",
|
||||
"#dd = widgets.Dropdown(options=['', 'foo', 'bar', 'baz'])\n",
|
||||
"#button = widgets.Button(description='Run', disabled=True)\n",
|
||||
"\n",
|
||||
"#def validation(ev):\n",
|
||||
"# \"make button clickable if user has put in more than 5 characters and chosen a dropdown option\"\n",
|
||||
"# if len(text.value) > 5 and dd.value:\n",
|
||||
"# button.disabled = False\n",
|
||||
"# else:\n",
|
||||
"# button.disabled = True\n",
|
||||
"#text.observe(validation)\n",
|
||||
"#dd.observe(validation)\n",
|
||||
"\n",
|
||||
"#box = widgets.VBox(children=[text, dd, button])\n",
|
||||
"#box = widgets.VBox(children=[text])\n",
|
||||
"#box"
|
||||
]
|
||||
},
|
||||
|
@ -59,22 +78,28 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# cell 1\n",
|
||||
"### cell #1\n",
|
||||
"textsize=False\n",
|
||||
"import ipywidgets as widgets\n",
|
||||
"import ipython_blocking\n",
|
||||
"text = widgets.Text()\n",
|
||||
"#dd = widgets.Dropdown(options=['', 'foo', 'bar', 'baz'])\n",
|
||||
"button = widgets.Button(description='Run', disabled=True)\n",
|
||||
"import ipython_blocking # enables %block and %blockrun magic\n",
|
||||
"\n",
|
||||
"def validation(ev):\n",
|
||||
" \"make button clickable if user has put in more than 5\"\n",
|
||||
"text = widgets.Text()\n",
|
||||
"\n",
|
||||
"button = widgets.Button(description='Run', disabled=False)\n",
|
||||
"\n",
|
||||
"#def validation(ev):\n",
|
||||
"def validation():\n",
|
||||
" if len(text.value) > 5:\n",
|
||||
" button.disabled = False\n",
|
||||
" return False\n",
|
||||
" else:\n",
|
||||
" button.disabled = True\n",
|
||||
" return \n",
|
||||
"\n",
|
||||
"#box = widgets.VBox(children=[text, button])\n",
|
||||
"#box = widgets.VBox(children=[button])\n",
|
||||
"\n",
|
||||
"text.observe(validation)\n",
|
||||
"\n",
|
||||
"box = widgets.VBox(children=[text, button])\n",
|
||||
"box = widgets.VBox(children=[text])\n",
|
||||
"box"
|
||||
]
|
||||
},
|
||||
|
@ -84,8 +109,10 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# cell 2\n",
|
||||
"%blockrun button"
|
||||
"### cell #2\n",
|
||||
"%block validation\n",
|
||||
"#%blockrun button\n",
|
||||
"#%blockrun button"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -94,19 +121,9 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# cell 3\n",
|
||||
"print(text.value)\n",
|
||||
"print(dd.value)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"blueline = widgets.Output(layout={'border': '5px solid lightblue'})\n",
|
||||
"blueline"
|
||||
"### cell #3 -- doesn't execute until the 'Run' button is pressed\n",
|
||||
"### This gives the user a chance to interact with the Text and Dropdown widgets\n",
|
||||
"print(text.value)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue