[IPython-User] question about frontend-kernel interaction
Zoltán Vörös
zvoros@gmail....
Sun Jul 8 01:43:15 CDT 2012
Hi all,
I would like to ask how the display function in the html notebook works.
I wanted to add some interactivity to plots. Here is a minimal example,
which should produce random plots on a button press in the notebook.
from IPython.core.display import display, HTML, clear_output
html = """<script type="text/javascript">
function jsfunction () {
IPython.notebook.kernel.execute("pyfunc()");
}
</script>
<input type="button" value="Replot" onclick="jsfunction()" />
"""
display(HTML(html))
f, ax = plt.subplots()
f.hold(False)
def pyfunc():
# clear_output()
# display(HTML(js))
f.clear()
plot(rand(100))
show()
If I call %pylab, this snippet populates the plot in a popup window, and
it does what I expect. However, when I call %pylab inline (in this case,
the two commented-out lines are part of the code), the plot is never
updated, and it seems to me that subsequent plots are never loaded to
the notebook. Could someone point out what is missing, or whether what I
want to do is doable at all?
Cheers,
Zoltán
More information about the IPython-User
mailing list