Fallback to ipywidgets

This commit is contained in:
Jonathan Frederic 2016-01-28 14:45:34 -08:00
parent e7bc3fcda6
commit ee7dd22ebe
2 changed files with 12 additions and 3 deletions

View File

@ -239,16 +239,21 @@ class NotebookWebApplication(web.Application):
handlers.extend(load_handlers('services.security.handlers'))
# BEGIN HARDCODED WIDGETS HACK
widgets = None
try:
widgets = __import__('jupyter-js-widgets-nbextension')
except:
try:
widgets = __import__('ipywidgets')
except:
app_log.warning('jupyter-js-widgets-nbextension package not installed. Widgets are unavailable.')
if widgets is not None:
handlers.append(
(r"/nbextensions/widgets/(.*)", FileFindHandler, {
'path': widgets.find_static_assets(),
'no_cache_paths': ['/'], # don't cache anything in nbextensions
}),
)
except:
app_log.warning('jupyter-js-widgets-nbextension package not installed. Widgets are unavailable.')
# END HARDCODED WIDGETS HACK
handlers.append(

View File

@ -55,8 +55,12 @@ require([
"use strict";
// BEGIN HARDCODED WIDGETS HACK
// Try to load the new extension
utils.load_extension('widgets/extension').catch(function () {
console.warn('ipywidgets package not installed. Widgets are not available.');
// Fallback to the ipywidgets extension
utils.load_extension('widgets/notebook/js/extension').catch(function () {
console.warn('ipywidgets package not installed. Widgets are not available.');
});
});
// END HARDCODED WIDGETS HACK