Created
August 28, 2014 13:33
-
-
Save rossant/8d8a7e39d286b179dd9d to your computer and use it in GitHub Desktop.
Minimal IPython widget example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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