diff --git a/notebooks/wut-web-dev.ipynb b/notebooks/wut-web-dev.ipynb index 57d20dd..8b1f280 100644 --- a/notebooks/wut-web-dev.ipynb +++ b/notebooks/wut-web-dev.ipynb @@ -27,6 +27,37 @@ "import ipywidgets as widgets" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "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", + "def on_click(btn):\n", + " global ui_done\n", + " ui_done = True\n", + " btn.description = '👍'\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, @@ -45,7 +76,7 @@ ")\n", "\n", "display(slider)\n", - "time.sleep(90) # move slider to 5" + "time.sleep(1) # move slider to 5" ] }, {