wut-web-dev cruft input tests wtf
parent
6900a4a772
commit
d05e802255
|
@ -33,128 +33,35 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import ipywidgets as w\n",
|
||||
"from IPython.display import display\n",
|
||||
"import time\n",
|
||||
"from ipywidgets import Button\n",
|
||||
"from jupyter_ui_poll import ui_events\n",
|
||||
"\n",
|
||||
"# Set up simple GUI, button with on_click callback\n",
|
||||
"# that sets ui_done=True and changes button text\n",
|
||||
"ui_done = False\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": [
|
||||
"def on_click(btn):\n",
|
||||
" global ui_done\n",
|
||||
" ui_done = True\n",
|
||||
" btn.description = '👍'\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",
|
||||
"\n",
|
||||
"btn = Button(description='Click Me')\n",
|
||||
"btn.on_click(on_click)\n",
|
||||
"display(btn)\n",
|
||||
"\n",
|
||||
"# Wait for user to press the button\n",
|
||||
"with ui_events() as poll:\n",
|
||||
" while ui_done is False:\n",
|
||||
" poll(10) # React to UI events (upto 10 at a time)\n",
|
||||
" print('.', end='')\n",
|
||||
" time.sleep(0.1)\n",
|
||||
"print('done')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"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(1) # 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 # enables %block and %blockrun magic\n",
|
||||
"\n",
|
||||
"#text = widgets.Text()\n",
|
||||
"#box = widgets.VBox(children=[text])\n",
|
||||
"#box"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"### cell #1\n",
|
||||
"textsize=False\n",
|
||||
"import ipywidgets as widgets\n",
|
||||
"import ipython_blocking # enables %block and %blockrun magic\n",
|
||||
"\n",
|
||||
"textmuh = widgets.Text()\n",
|
||||
"\n",
|
||||
"buttonmuh = widgets.Button(description='Run', disabled=False)\n",
|
||||
"\n",
|
||||
"#def validation(ev):\n",
|
||||
"def validation():\n",
|
||||
" if len(textmuh.value) > 5:\n",
|
||||
" return False\n",
|
||||
" else:\n",
|
||||
" return \n",
|
||||
"\n",
|
||||
"#box = widgets.VBox(children=[text, button])\n",
|
||||
"#box = widgets.VBox(children=[button])\n",
|
||||
"\n",
|
||||
"textmuh.observe(validation)\n",
|
||||
"\n",
|
||||
"box = widgets.VBox(children=[textmuh])\n",
|
||||
"box"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"### cell #2\n",
|
||||
"#%block validation\n",
|
||||
"#%blockrun button\n",
|
||||
"#%blockrun button"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"### 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(textmuh.value)"
|
||||
"display(test_button())\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -167,39 +74,6 @@
|
|||
"blueline"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from ipywidgets import interact, widgets\n",
|
||||
"from IPython.display import display\n",
|
||||
"\n",
|
||||
"text22 = widgets.Text(\n",
|
||||
" value='last',\n",
|
||||
" placeholder='Paste ticket description here!',\n",
|
||||
" description='String:',\n",
|
||||
" disabled=False\n",
|
||||
")\n",
|
||||
"display(text22)\n",
|
||||
"\n",
|
||||
"def callback(wdgt):\n",
|
||||
" # replace by something useful\n",
|
||||
" display(wdgt.value)\n",
|
||||
"\n",
|
||||
"text22.on_submit(callback)\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,
|
||||
|
@ -383,16 +257,6 @@
|
|||
"#obs_file='/srv/satnogs/download/1456893/1456893.json'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from IPython.display import display_pretty\n",
|
||||
"#display_pretty(obs_file)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
@ -417,38 +281,6 @@
|
|||
"display(obs_html)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from IPython.display import SVG\n",
|
||||
"#spacelogo='/srv/satnogs/satnogs-wut/pics/spacecruft.svg'\n",
|
||||
"#spacesvg=SVG(filename=spacelogo)\n",
|
||||
"#display(spacesvg)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from IPython.utils.sysinfo import sys_info\n",
|
||||
"sys_info()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from IPython.utils.sysinfo import num_cpus\n",
|
||||
"num_cpus()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
@ -462,19 +294,6 @@
|
|||
"#text.SList(waterfallpng)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"a = !ls -l\n",
|
||||
"print(a)\n",
|
||||
"#a.fields(0)\n",
|
||||
"#a.fields(1,0)\n",
|
||||
"a.fields(-1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
@ -496,56 +315,6 @@
|
|||
"print(text.marquee('wut?',40,'*'))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#a = input()\n",
|
||||
"#print(a)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print('mkay')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from ipywidgets import widgets\n",
|
||||
"#text=\"foo\"\n",
|
||||
"text1=widgets.Text()\n",
|
||||
"display(text1)\n",
|
||||
"#on_submit()\n",
|
||||
"btn=widgets.Button(description='foo')\n",
|
||||
"display(btn)\n",
|
||||
"\n",
|
||||
"def seee(b):\n",
|
||||
" woo=text1.value\n",
|
||||
" print(woo)\n",
|
||||
" \n",
|
||||
"btn.on_click(seee)\n",
|
||||
"print(\"meh\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print('meh2')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
@ -556,52 +325,6 @@
|
|||
"blueline"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"outputText = widgets.Text()\n",
|
||||
"outputText"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#inputText = widgets.Text()\n",
|
||||
"\n",
|
||||
"#def makeUpperCase(sender):\n",
|
||||
"# outputText.value = inputText.value.upper()\n",
|
||||
"\n",
|
||||
"#inputText.on_submit(makeUpperCase)\n",
|
||||
"#inputText"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"blueline = widgets.Output(layout={'border': '5px solid lightblue'})\n",
|
||||
"blueline"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#b = widgets.IntSlider(min=1292461, max=1470525, step=1, value=1456893, continuous_update=True, description='Observation ID:', orientation='vertical', readout=True)\n",
|
||||
"#display(obsget,b)\n",
|
||||
"#mylink = widgets.jslink((obsget, 'value'), (b, 'value'))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
@ -644,102 +367,6 @@
|
|||
"obsinputText"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#obsget = widgets.Text(value='1456893', disabled=False)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#def showObs(sender):\n",
|
||||
"# #print('Get Obs ID:', obsget.value)\n",
|
||||
"# obsoutputText.value = inputText.obsget.upper()\n",
|
||||
"\n",
|
||||
"#obsget = widgets.IntText(value=1456893, disabled=False)\n",
|
||||
"#obsget.on_submit(showObs)\n",
|
||||
"#obsget\n",
|
||||
"\n",
|
||||
"#print(obsget.value)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"blueline = widgets.Output(layout={'border': '5px solid lightblue'})\n",
|
||||
"blueline"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#text = widgets.Text()\n",
|
||||
"#display(text)\n",
|
||||
"\n",
|
||||
"#def handle_submit(sender):\n",
|
||||
"# print(text.value)\n",
|
||||
"\n",
|
||||
"#text.on_submit(handle_submit)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"blueline = widgets.Output(layout={'border': '5px solid lightblue'})\n",
|
||||
"blueline"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"text=widgets.Text()\n",
|
||||
"display(text)\n",
|
||||
"\n",
|
||||
"def handle_submit(sender):\n",
|
||||
" print(text.value)\n",
|
||||
"\n",
|
||||
"text.on_submit(handle_submit)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"blueline = widgets.Output(layout={'border': '5px solid lightblue'})\n",
|
||||
"blueline"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from IPython.display import HTML\n",
|
||||
"#HTML('<iframe src=https://wiki.satnogs.org/DUV width=1024 height = 500></iframe>')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
|
Loading…
Reference in New Issue