ipython: Creating a new notebook cell from within a widget does not work.
While testing the new widget framework, I expected that I could create new cell in the notebook clicking a widget. (The underlying idea is to propose a widget that helps creating plotting python code by selecting data interactively.) Here is a minimal piece of code that reveal the problem:
from IPython.html import widgets
from IPython.display import display
def create(button):
get_ipython().set_next_input('print "test"')
button = widgets.ButtonWidget(description="Create next input")
button.on_click(create)
display(button)
Execute this code in a notebook cell, click the “Create next input” button. I would expect a new cell to appear but it does not. (Using the latest head from master)
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 2
- Comments: 26 (10 by maintainers)
Hi @davidtrem ,
I did not close this because it was fixed, because it is not fixed yet. I closed this because it was part of a bigger problem - see #5006.
I whipped up a quick function that will do what you want:
The following shows how this can be used with a button widget:
I know this is much uglier, when #5006 is addressed completely, you should be able to use the built-in API you referenced.