Last active
August 29, 2015 14:23
-
-
Save bbartley/b24aeb1fb52c50698ad5 to your computer and use it in GitHub Desktop.
Example of a custom widget for iPython 3.1 notebook
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
/* Should be placed inside your .ipython/nbextensions folder */ | |
require(["widgets/js/widget", "widgets/js/manager"], function(widget, manager){ | |
console.log('Module loaded'); | |
var CustomPickerView = widget.DOMWidgetView.extend({ | |
// Render the view. | |
render: function(){ | |
this.$el.text('Hello World!'); | |
}, | |
update: function(options) { | |
console.log("doing update"); | |
} | |
}); | |
//manager.WidgetManager.register_widget_view('CustomPickerView', CustomPickerView); | |
return {CustomPickerView: CustomPickerview}; | |
}); |
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
/* Import the CustomWidget into your iPython notebook */ | |
from IPython.html import widgets # Widget definitions | |
from IPython.display import display # Used to display widgets in the notebook | |
from IPython.display import Javascript | |
from IPython.utils.traitlets import Unicode # Used to declare attributes of our widget | |
class CustomWidget(widgets.DOMWidget): | |
_view_name = Unicode('CustomPickerView', sync=True) | |
_view_module = Unicode("nbextensions/CustomWidget", sync=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment