Skip to content

Instantly share code, notes, and snippets.

@rossant
Created August 28, 2014 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rossant/8d8a7e39d286b179dd9d to your computer and use it in GitHub Desktop.
Save rossant/8d8a7e39d286b179dd9d to your computer and use it in GitHub Desktop.
Minimal IPython widget example
from IPython.html import widgets
from IPython.utils.traitlets import Unicode
class MyWidget(widgets.DOMWidget):
_view_name = Unicode('MyWidget', sync=True)
%%javascript
require(["widgets/js/widget"], function(WidgetManager){
var MyWidget = IPython.DOMWidgetView.extend({
render: function(){
this.$el.text('Hello World!');
},
});
WidgetManager.register_widget_view('MyWidget', MyWidget);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment