wut-web-dev cruft input tests wtf

master
ml server 2020-01-23 19:37:31 -07:00
parent f9bfe3a1b5
commit f1f8ab8d9d
1 changed files with 1 additions and 115 deletions

View File

@ -29,121 +29,7 @@
"metadata": {},
"outputs": [],
"source": [
"display(Image(filename='/srv/satnogs/satnogs-wut/pics/spacecruft-bk.png'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as w\n",
"from IPython.display import display\n",
"import time\n",
"from jupyter_ui_poll import (\n",
" ui_events, \n",
" with_ui_events,\n",
" run_ui_poll_loop\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"display(Image(filename='/srv/satnogs/satnogs-wut/pics/spacecruft-bk.png'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def on_click(btn):\n",
" n = int(btn.description)\n",
" btn.description = str(n+1)\n",
" \n",
"def test_button():\n",
" \"\"\"\n",
" Create button that displays number of times it was clicked\n",
" \"\"\"\n",
" btn = w.Button(description=\"0\")\n",
" btn.on_click(on_click)\n",
" return btn\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"display(Image(filename='/srv/satnogs/satnogs-wut/pics/spacecruft-bk.png'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"t0 = time.time()\n",
"xx = ['-_-', 'o_o']\n",
"\n",
"def on_poll():\n",
" \"\"\" This is called repeatedly by run_ui_poll_loop\n",
" \n",
" Return None if condition hasn't been met yet\n",
" \n",
" Return some result once done, in this example result \n",
" is a number of seconds it took to press the button 10 times.\n",
" \"\"\"\n",
" if int(btn.description) < 10:\n",
" print(xx[0], end='\\r', flush=True)\n",
" xx[:] = xx[::-1]\n",
" return None # Continue polling\n",
" \n",
" # Terminate polling and return final result\n",
" return time.time() - t0\n",
"\n",
"btn = test_button()\n",
"print('Press button 10 times')\n",
"display(btn)\n",
"\n",
"dt = run_ui_poll_loop(on_poll, 1/15)\n",
"print('._.') # This should display the text in the output of this cell\n",
"n_times = '10 times' # To verify that the rest of this cell executes before executing cells below"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"display(Image(filename='/srv/satnogs/satnogs-wut/pics/spacecruft-bk.png'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(f'Took {dt:.1f} seconds to click {n_times}')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"display(Image(filename='/srv/satnogs/satnogs-wut/pics/spacecruft-bk.png'))"
"#display(Image(filename='/srv/satnogs/satnogs-wut/pics/spacecruft-bk.png'))"
]
},
{