mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-15 04:00:34 +08:00
Fallback to ipywidgets
This commit is contained in:
parent
e7bc3fcda6
commit
ee7dd22ebe
@ -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(
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user