Created
December 27, 2018 20:09
-
-
Save mwcraig/dfbc8b902b5cc8ef51ab541cbc954279 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Using WorldWide Telescope inside the Jupyter notebook" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"This notebook shows how to start up the WorldWide Telescope Jupyter widget, and how to subsequently modify its properties. You can find out more about using pywwt in the [documentation](http://pywwt.readthedocs.io).\n", | |
"\n", | |
"We start off by importing the ``WWTJupyterWidget`` class:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from pywwt.jupyter import WWTJupyterWidget\n", | |
"from ipywidgets import HBox, IntSlider\n", | |
"from ipyevents import Event\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"We then use this class to create the widget (note that the second ``wwt`` is needed to actually show the contents of the widget):" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"scrolled": false | |
}, | |
"outputs": [], | |
"source": [ | |
"wwt = WWTJupyterWidget()" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Scrolling is suppressed *except* over wwt\n", | |
"\n", | |
"Anything on or inside the red border has scrolling of the outer page suppressed except the wwt widget." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"s = IntSlider()\n", | |
"hb = HBox()\n", | |
"hb.children = [wwt, s]\n", | |
"hb.layout.border = \"2px solid red\"\n", | |
"hb.layout.padding = \"20px\"\n", | |
"\n", | |
"e = Event()\n", | |
"e.source = hb\n", | |
"e.watched_events = ['wheel']\n", | |
"\n", | |
"hb" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"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.6.7" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment