{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Overview\n", "\n", "Behind the scenes, even pure Python widgets are composed of two pieces:\n", "\n", "+ Python, which runs in the notebook kernel.\n", "+ Javascript, which runs in the browser.\n", "\n", "When writing your own widgets, that means making a choice: write only in Python or write in both Python and Javascript.\n", "\n", "Which to choose depends on what you are trying to accomplish. This tutorial will focus on writing your own widgets in pure Python. An example of a pure-Python package that includes some interesting interfaces is [reducer](http://reducer.readthedocs.io), a package for calibrating astronomical data.\n", "\n", "What you can accomplish with just Python has increased quite a bit in the last year or two as more sophisticated tools that plug in to the Jupyter widget ecosystem have been written.\n", "\n", "One of those tools is [bqplot](https://github.com/bloomberg/bqplot/blob/master/examples/Index.ipynb), which provides a plotting tools in which the plot, and the lines, markers, labels and legend, all act as widgets. That required both Python *and* javascript. On the javacsript side bqplot uses [d3](https://d3js.org/) to do the drawing in the browser. \n", "\n", "Another example is [ipyvolume](https://ipyvolume.readthedocs.io/en/latest/), which does three-dimensional renderings of point or volumetric data in the browser. It has both Python and javascript pieces.\n", "\n", "One last addition is in `ipywidgets` itself: the new `Output` widget can display any content which can be rendered in a Jupyter notebook. That means that anything you can show in a notebook you can include in a widget using only Python." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Our destination, in a nutshell\n", "\n", "+ Green: [pythreejs](https://github.com/jupyter-widgets/pythreejs)\n", "+ Blue: [bqplot](https://github.com/bloomberg/bqplot/blob/master/examples/Index.ipynb)\n", "+ Everything else: [ipywidgets](https://github.com/jupyter-widgets/ipywidgets)\n", "+ Serving it up to users during development on [mybinder.org](https://mybinder.org/)\n", "\n", "![Binary Star Simulator](images/Binary_Star_Sim.png)\n", "\n", "### Source for this example (including links to binder): https://github.com/JuanCab/AstroInteractives\n", "\n", "[Video](https://youtu.be/kbgST0uifvM)" ] } ], "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.4" } }, "nbformat": 4, "nbformat_minor": 2 }