This seems really simple but I have not been able to find a single example or to solve this myself. How do I use an ipywidget widget to create or return a python variable/object, such as a list or string, that can be used in a following cell?
相关问题
- Access IPython's profile history (history.sqli
- Requests.get showing different HTML than Chrome
- tf.enable_eager_execution must be called at progra
- ipywidgets widgets values not changing
- Pandas and NumPy default width change on startup
相关文章
- cython in jupyter notebook
- python: ignoring leading “>>>” and “…” in interact
- Pyspark error: Java gateway process exited before
- how to print source code of object I defined use
- IPython won't start
- Jupyter Notebook doesn't show new environments
- Display animation outside of jupyter notebook
- Ipython kernel error after uninstalling anaconda
Another solution that may be easier is to use
interactive
. It acts a lot likeinteract
, but allows you access to the returned value in later cells while creating only a single widget.A simple example is below, and more complete documentation is here
You can now access the result value, and also the values of the widgets if desired.
There is a good introduction to ipywidgets at http://blog.dominodatalab.com/interactive-dashboards-in-jupyter/ which answers this question.
You need two widgets, one for input, and another to bind the value of that input. Here's an example for text input:
You can then use the uppercase_string, or output_text.value string, for example, throughout your notebook.
A similar pattern can be followed for using other input values, e.g. the interact() slider: