-
-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix various gallery examples (#2050)
- Loading branch information
1 parent
709ef9b
commit 01869de
Showing
3 changed files
with
176 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import time\n", | ||
"import panel as pn\n", | ||
"import holoviews as hv\n", | ||
"import numpy as np\n", | ||
"\n", | ||
"pn.extension(loading_spinner='dots', loading_color='#00aa41')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Every pane, widget and layout provides the `loading` parameter. When set to `True` a spinner will overlay the panel and indicate that the panel is currently loading. When you set `loading` to false the spinner is removed. Using the `pn.extension` or by setting the equivalent parameters on `pn.config` we can select between different visual styles and colors for the loading indicator.\n", | ||
"\n", | ||
"Using the `pn.param.set_values` context manager we can set the `loading` parameter to `True` while we perform some computation (here simulated using `time.sleep`:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"button = pn.widgets.Button(name=\"Update\", margin=(0, 32, 0, 57))\n", | ||
"\n", | ||
"def random_plot():\n", | ||
" return hv.Points(np.random.rand(100, 2)).opts(\n", | ||
" width=400, height=400, size=5)\n", | ||
"\n", | ||
"hv_pane = pn.pane.HoloViews(random_plot())\n", | ||
"\n", | ||
"def update(event):\n", | ||
" with pn.param.set_values(hv_pane, loading=True):\n", | ||
" time.sleep(10)\n", | ||
" hv_pane.object = random_plot()\n", | ||
" \n", | ||
"button.on_click(update)\n", | ||
"\n", | ||
"pn.Column(button, hv_pane).servable()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.2" | ||
}, | ||
"widgets": { | ||
"application/vnd.jupyter.widget-state+json": { | ||
"state": {}, | ||
"version_major": 2, | ||
"version_minor": 0 | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |