Titus Barik
unread,Sep 10, 2018, 1:42:34 PM9/10/18Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to jup...@googlegroups.com
Hi all,
Apologies for the newbie question.
How does one design a Jupyter widget (DOMWidget) that can modify the notebook itself? For example, given a sample DOMWidget, let's say I want a button that upon clicking inserts a new cell:
define('hello', ["@jupyter-widgets/base"], function(widgets) {
var HelloView = widgets.DOMWidgetView.extend({
// Render the view.
render: function() {
this.el = /* creates some sort of HTML button */;
},
});
return {
HelloView: HelloView
};
});
Is the right thing to do to modify render, render an HTML button, and then have its onclick event perform something like:
IPython.notebook.insert_cell_below('code').set_text('some text');
Or is there some better/more appropriate strategy?
Thanks.