├── ipywidgets
├── __init__.py
├── interact.py
└── widgets.py
├── .gitignore
├── README.md
├── setup.py
├── LICENSE
└── TODO.md
/ipywidgets/__init__.py:
--------------------------------------------------------------------------------
1 | __version__ = "0.0.1"
2 |
3 | from .interact import StaticInteract
4 | from .widgets import RadioWidget, RangeWidget, DropDownWidget
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.py[cod]
2 |
3 | # C extensions
4 | *.so
5 |
6 | # Packages
7 | *.egg
8 | *.egg-info
9 | dist
10 | build
11 | eggs
12 | parts
13 | bin
14 | var
15 | sdist
16 | develop-eggs
17 | .installed.cfg
18 | lib
19 | lib64
20 | __pycache__
21 |
22 | # Installer logs
23 | pip-log.txt
24 |
25 | # Unit test / coverage reports
26 | .coverage
27 | .tox
28 | nosetests.xml
29 |
30 | # Translations
31 | *.mo
32 |
33 | # Mr Developer
34 | .mr.developer.cfg
35 | .project
36 | .pydevproject
37 |
38 |
39 | # emacs
40 | *~
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Static Widgets for IPython Notebooks
2 | ====================================
3 |
4 | **Note that this package is no longer supported; instead, use IPython's built-in interactive tools: https://github.com/ipython/ipywidgets**
5 |
6 | This is currently an experimental repository containing code which enables
7 | static widgets to be used in the IPython notebook.
8 |
9 | Use at your own risk: the interface will likely change in the near future...
10 |
11 | Demonstrations
12 | --------------
13 | You can see this in action in a few places:
14 |
15 | - My [blog post](http://jakevdp.github.io/blog/2013/12/05/static-interactive-widgets/) about starting this repository
16 | - The [example notebook](http://nbviewer.ipython.org/github/jakevdp/ipywidgets/blob/master/example.ipynb) in this repository
17 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from distutils.core import setup
2 |
3 | DESCRIPTION = "IPython Static Widgets"
4 | LONG_DESCRIPTION = DESCRIPTION
5 | NAME = "ipywidgets"
6 | AUTHOR = "Jake VanderPlas"
7 | AUTHOR_EMAIL = "jakevdp@cs.washington.edu"
8 | MAINTAINER = "Jake VanderPlas"
9 | MAINTAINER_EMAIL = "jakevdp@cs.washington.edu"
10 | DOWNLOAD_URL = 'http://github.com/jakevdp/ipywidgets'
11 | LICENSE = 'BSD'
12 |
13 | VERSION = '0.0.1'
14 |
15 | setup(name=NAME,
16 | version=VERSION,
17 | description=DESCRIPTION,
18 | long_description=LONG_DESCRIPTION,
19 | author=AUTHOR,
20 | author_email=AUTHOR_EMAIL,
21 | maintainer=MAINTAINER,
22 | maintainer_email=MAINTAINER_EMAIL,
23 | url=DOWNLOAD_URL,
24 | download_url=DOWNLOAD_URL,
25 | license=LICENSE,
26 | packages=['ipywidgets'],
27 | )
28 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013, Jake Vanderplas
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification,
5 | are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | list of conditions and the following disclaimer in the documentation and/or
12 | other materials provided with the distribution.
13 |
14 | * Neither the name of the {organization} nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/TODO.md:
--------------------------------------------------------------------------------
1 | # To Do
2 | There are various issues here...
3 |
4 | ## Output CSS Tags
5 | The widgets should have css attributes that allow their style to be tweaked.
6 | Also, we need better labeling options for the widgets.
7 |
8 | ## HTML renderings
9 | Currently the HTML rendering of arbitrary objects uses either the raw text
10 | format or the png format. It should be possible to use the standard
11 | IPython display tools to do this the right way. According to @minrk and
12 | @ellisonbg via the IPython dev hipchat:
13 |
14 | > if you just call OutputArea.append_mime_type(json, your_element, true), you should get back `your_element` with the rendered output attached.
15 | > Or if you instantiate OutputArea and pass it the div you want output in you can just call the top level handle output with the JSON
16 | > you could easily build that JSON from the display_formatter JSON
17 | > The message spec docs would show you how to build that
18 | > http://ipython.org/ipython-doc/dev/development/messaging.html#display-data
19 | >
20 | > Basically it is just a matter of top level content attribute with data
21 | > and metadata subattributes that contain the display JSON
22 | >
23 | > I think all you need is the publish method of displaypub:
24 | > https://github.com/ipython/ipython/blob/master/IPython/kernel/zmq/zmqshell.py#L77
25 | > (data, metadata) is what formatter.format(obj) returns
26 | >
27 |
28 |
29 | ## Working with float-values
30 | Widgets with floating-point values don't always work, because of the differences
31 | in the way Python and Javascript represent floats.
32 |
33 | ## Other widgets
34 | Currently only radio buttons and sliders are implemented. Are there other
35 | widgets that should be included?
36 |
37 | ## Animations
38 | This is a much better approach than that used in the ``JSAnimation`` library.
39 | It would be nice to re-build those animation tools in the style used here, and
40 | to include animations in this library
41 |
42 | ## Compression
43 | These things can get really big really fast. Implementing some sort of image
44 | compression into this would be really, really useful.
45 |
--------------------------------------------------------------------------------
/ipywidgets/interact.py:
--------------------------------------------------------------------------------
1 | from collections import OrderedDict
2 | import itertools
3 | import matplotlib.pyplot as plt
4 | from IPython import get_ipython
5 |
6 |
7 | def _get_html(obj):
8 | """Get the HTML representation of an object"""
9 | # TODO: use displaypub to make this more general
10 | ip = get_ipython()
11 | png_rep = ip.display_formatter.formatters['image/png'](obj)
12 |
13 | if png_rep is not None:
14 | if isinstance(obj, plt.Figure):
15 | plt.close(obj) # keep from displaying twice
16 | return (''.format(png_rep.encode('base64')))
18 | else:
19 | return "
{0}
".format(str(obj)) 20 | 21 | rep = ip.display_formatter.formatters['text/html'](obj) 22 | 23 | if rep is not None: 24 | return rep 25 | elif hasattr(obj, '_repr_html_'): 26 | return obj._repr_html_() 27 | 28 | 29 | class StaticInteract(object): 30 | """Static Interact Object""" 31 | 32 | template = """ 33 | 66 | 67 |