Comments (5)
Also, here's a more functional example of updating an output widget from a button click callback, to show how this can be used to position output (e.g. a matplotlib plot) relative to other widgets:
%matplotlib inline
# To prevent automatic figure display when execution of the cell ends
%config InlineBackend.close_figures=False
import matplotlib.pyplot as plt
import numpy as np
from IPython.html import widgets
from IPython.display import display,clear_output
plt.ioff()
ax=plt.gca()
plt.plot(np.random.randn(100),np.random.randn(100),'+')
out=widgets.Output()
button=widgets.Button(description='Next')
vbox=widgets.VBox(children=(out,button))
display(vbox)
def click(b):
ax.lines[0].set_xdata(np.random.randn(100))
ax.lines[0].set_ydata(np.random.randn(100))
with out:
clear_output(wait=True)
display(ax.figure)
button.on_click(click)
click(None)
from ipywidgets.
The minimal test case above raises another potential issue, but I haven't convinced myself that this is not just an error on my part:
When the button is clicked, only blank space is added to the output widget. 'Hello world' is not printed.
from ipywidgets.
from IPython import get_ipython
to IPython/html/widgets/widget_output.py, but I'm not familiar enough with the code to be sure if this is the correct place to make that change, or if the fix should be further upstream.
That's right, get_ipython() used to be available globally, looks like that's no longer the case after the big split.
Thanks for the excellent example of how a plot can be relocated! Feel free to open a PR to add that to the examples folder.
The minimal test case above raises another potential issue, but I haven't convinced myself that this is not just an error on my part:
When the button is clicked, only blank space is added to the output widget. 'Hello world' is not printed.
I wasn't able to reproduce this, it may be fixed in master.
from ipywidgets.
That's right, get_ipython() used to be available globally, looks like that's no longer the case after the big split.
Since the bug report is using IPython prior to the split, I don't think that's the case. The issue is that we inject get_ipython
into globals only while interactive user code is running. Comm messages may not be handled in that context (arguable whether they should be). In general, though, no library code should rely on get_ipython
in globals, and always import it. Only interactively typed code should access it via globals.
from ipywidgets.
Thanks for clarifying @minrk
from ipywidgets.
Related Issues (20)
- Reopening and saving a notebook with a stored widget state will delete that state.
- Cannot always edit bounds in readout of `FloatRangeSlider`
- Output with traitlets class only update once in jupyterlab
- Better error messaging for "model not found" HOT 1
- Output widget does not capture print under IPython's `%%capture` magic
- AttributeError: 'DummyComm' object has no attribute 'messages' HOT 1
- HTMLManager uses hardcoded entrypoint (`dist/<name>.js`) for extensions
- interact: add slider init-value support when passing a tuple
- Rendering output from within async function does not work as intended
- Failed to register jupyter_bokeh
- To HTML converted notebooks are not displayed (due to embed.amd.js) HOT 1
- add class management function to the DOMWidget class
- Simple representation, str method for Layout
- Proposal: allow `interact` to use type hint annotations for abbreviations
- Spinning icon not working with VS Code HOT 1
- input widget values cannot be changed by keyboard inputs with `notebook 7.1.x ` HOT 2
- Icons don't show on buttons HOT 5
- Dropdown key inputs stolen by JLab when the dropdown is collapsed
- Improve error message if a frontend version is not valid
- Sending message from javascript view class to python not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipywidgets.