\u001b[0m in \u001b[0;36mfunction_with_captured_output\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mfunction_with_captured_output\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'This goes into the output widget'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'As does this'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0mfunction_with_captured_output\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;31mException\u001b[0m: As does this"
+ ]
+ }
+ ]
+ }
+ },
+ "df9a09ac807740ec8f99b2fbdd084ca3": {
+ "model_module": "@jupyter-widgets/base",
+ "model_module_version": "1.0.0",
+ "model_name": "LayoutModel",
+ "state": {}
+ },
+ "eb7440e7cb654ef1b81456201ad73046": {
+ "model_module": "@jupyter-widgets/base",
+ "model_module_version": "1.0.0",
+ "model_name": "LayoutModel",
+ "state": {
+ "border": "1px solid black"
+ }
+ },
+ "f293dd82b7cf4c62ab33fb92e6dbbfd0": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_module_version": "1.1.0",
+ "model_name": "SliderStyleModel",
+ "state": {
+ "description_width": ""
+ }
+ }
+ },
+ "version_major": 2,
+ "version_minor": 0
+ }
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 1
+}
diff --git a/docs/source/examples/Widget Asynchronous.ipynb b/docs/source/examples/Widget Asynchronous.ipynb
index 9d842dd164..6246fb40ca 100644
--- a/docs/source/examples/Widget Asynchronous.ipynb
+++ b/docs/source/examples/Widget Asynchronous.ipynb
@@ -280,75 +280,6 @@
"thread.start()"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Interacting with output widgets from background threads\n",
- "\n",
- "Output widgets capture output based on the thread in which they were invoked.\n",
- "In other words, in the thread where the output is invoked, there is a context\n",
- "manager which starts and then stops the output capturing. If you call `display`\n",
- "in a thread other than the thread containing the context manager, you cannot\n",
- "rely on those `display` calls being captured by the context manager.\n",
- "\n",
- "Instead, we can pass an `Output` widget to the function executing in a thread,\n",
- "and use the `Output`'s `append_display_data()`, `append_stdout()`, or\n",
- "`append_stderr()` methods to append displayable output (such as from `HTML()`),\n",
- "standard output (such as from `print()`), or standard error to the `Output`\n",
- "widget."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "'Display in main thread'"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "32e8e3b06ec44fabb832283d779fda97",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "A Jupyter Widget"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "import threading\n",
- "from IPython.display import display, HTML\n",
- "import ipywidgets as widgets\n",
- "\n",
- "def thread_func(something, out):\n",
- " for i in range(1, 10):\n",
- " out.append_stdout('{} {} {}\\n'.format(i, '**'*i, something))\n",
- " out.append_display_data(HTML(\"All done!
\"))\n",
- "\n",
- "display('Display in main thread')\n",
- "out = widgets.Output()\n",
- "# Now the key: the container is displayed (while empty) in the main thread\n",
- "display(out)\n",
- "\n",
- "thread = threading.Thread(\n",
- " target=thread_func,\n",
- " args=(\"some text\", out))\n",
- "thread.start()"
- ]
- },
{
"cell_type": "markdown",
"metadata": {
diff --git a/docs/source/examples/Widget Events.ipynb b/docs/source/examples/Widget Events.ipynb
index 1e06ce5410..28f59bafc8 100644
--- a/docs/source/examples/Widget Events.ipynb
+++ b/docs/source/examples/Widget Events.ipynb
@@ -6,7 +6,7 @@
"nbsphinx": "hidden"
},
"source": [
- "[Index](Index.ipynb) - [Back](Widget List.ipynb) - [Next](Widget Styling.ipynb)"
+ "[Index](Index.ipynb) - [Back](Output Widget.ipynb) - [Next](Widget Styling.ipynb)"
]
},
{
@@ -664,7 +664,7 @@
"nbsphinx": "hidden"
},
"source": [
- "[Index](Index.ipynb) - [Back](Widget List.ipynb) - [Next](Widget Styling.ipynb)"
+ "[Index](Index.ipynb) - [Back](Output Widget.ipynb) - [Next](Widget Styling.ipynb)"
]
}
],
diff --git a/docs/source/examples/Widget List.ipynb b/docs/source/examples/Widget List.ipynb
index 8b716251a2..5221ce102a 100644
--- a/docs/source/examples/Widget List.ipynb
+++ b/docs/source/examples/Widget List.ipynb
@@ -6,7 +6,7 @@
"nbsphinx": "hidden"
},
"source": [
- "[Index](Index.ipynb) - [Back](Widget Basics.ipynb) - [Next](Widget Events.ipynb)"
+ "[Index](Index.ipynb) - [Back](Widget Basics.ipynb) - [Next](Output Widget.ipynb)"
]
},
{
@@ -1711,83 +1711,7 @@
"source": [
"## Output\n",
"\n",
- "The `Output` widget can capture and display stdout, stderr and [rich output generated by IPython](http://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html#module-IPython.display). After the widget is created, direct output to it using a context manager."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 31,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "af846c1a29fc4bd8bb0604e4090914d5",
- "version_major": 2,
- "version_minor": 0
- },
- "text/html": [
- "Failed to display Jupyter Widget of type Output
.
\n",
- "\n",
- " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
- " that the widgets JavaScript is still loading. If this message persists, it\n",
- " likely means that the widgets JavaScript library is either not installed or\n",
- " not enabled. See the Jupyter\n",
- " Widgets Documentation for setup instructions.\n",
- "
\n",
- "\n",
- " If you're reading this message in another frontend (for example, a static\n",
- " rendering on GitHub or NBViewer),\n",
- " it may mean that your frontend doesn't currently support widgets.\n",
- "
\n"
- ],
- "text/plain": [
- "Output()"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "out = widgets.Output()\n",
- "out"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "You can print text to the output area as shown below."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 32,
- "metadata": {},
- "outputs": [],
- "source": [
- "with out:\n",
- " for i in range(10):\n",
- " print(i, 'Hello world!')"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Rich material can also be directed to the output area. Anything which displays nicely in a Jupyter notebook will also display well in the `Output` widget."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 33,
- "metadata": {},
- "outputs": [],
- "source": [
- "from IPython.display import YouTubeVideo\n",
- "with out:\n",
- " display(YouTubeVideo('eWzY2nGfkXk'))"
+ "The `Output` widget can capture and display stdout, stderr and [rich output generated by IPython](http://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html#module-IPython.display). For detailed documentation, see the [output widget examples](/examples/Output Widget.html)."
]
},
{
@@ -2357,7 +2281,7 @@
"nbsphinx": "hidden"
},
"source": [
- "[Index](Index.ipynb) - [Back](Widget Basics.ipynb) - [Next](Widget Events.ipynb)"
+ "[Index](Index.ipynb) - [Back](Widget Basics.ipynb) - [Next](Output Widget.ipynb)"
]
}
],
diff --git a/docs/source/user_guide.rst b/docs/source/user_guide.rst
index 4d2c713610..4597a7ae6e 100644
--- a/docs/source/user_guide.rst
+++ b/docs/source/user_guide.rst
@@ -8,6 +8,7 @@ User Guide
examples/Using Interact.ipynb
examples/Widget Basics.ipynb
examples/Widget List.ipynb
+ examples/Output Widget.ipynb
examples/Widget Events.ipynb
examples/Widget Styling.ipynb
examples/Widget Custom.ipynb