【发布时间】:2017-08-01 17:48:15
【问题描述】:
是否可以自定义 jupyter notebook 前端部分(不仅仅是 css)? 基本上,我想为我的自定义 html 页面提供服务,该页面具有代码块,我想要在 Jupyter 笔记本中使用单元格的功能。我可以自定义页面的样式,但没有找到任何方法来更改布局 (html)。
【问题讨论】:
标签: python user-interface jupyter-notebook ipython jupyterhub
是否可以自定义 jupyter notebook 前端部分(不仅仅是 css)? 基本上,我想为我的自定义 html 页面提供服务,该页面具有代码块,我想要在 Jupyter 笔记本中使用单元格的功能。我可以自定义页面的样式,但没有找到任何方法来更改布局 (html)。
【问题讨论】:
标签: python user-interface jupyter-notebook ipython jupyterhub
您可以使用custom.js 文件(与您可能正在编辑的custom.css 文件位于同一位置)在页面加载时加载任意Javascript。您可以使用它来修改 DOM,例如使用 JQuery。或者,如果您打算进行更复杂的工作或分发您的 javascript,最好进行扩展 (http://jupyter-notebook.readthedocs.io/en/latest/extending/frontend_extensions.html)
如果我具体知道您要做什么,我可以尝试帮助举个例子,但这里是关于如何编写 custom.js 文件的基本框架:
define([
'base/js/namespace',
'base/js/events'
], function(Jupyter, events) {
events.on('app_initialized.NotebookApp', function(){
//your custom code here
});
});
【讨论】: