-
Notifications
You must be signed in to change notification settings - Fork 943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Displaying to output widget from button click callback throws exception #134
Comments
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. |
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) |
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.
I wasn't able to reproduce this, it may be fixed in master. |
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 |
Thanks for clarifying @minrk |
Here's a minimal example:
Executing a notebook cell with this code and clicking the button results in the following exception being thrown:
This is with the Anaconda ipython / ipython-notebook version 3.2.1 packages on Windows.
This issue can be resolved by adding
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.The text was updated successfully, but these errors were encountered: