如何在Jupyter Notebook仪表板的工具栏中添加操作? [英] How can I add Actions to the tool-bar in the Dashboard of Jupyter Notebook?

查看:226
本文介绍了如何在Jupyter Notebook仪表板的工具栏中添加操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Jupyter Notebook创建自定义前端扩展.这些动作将通过Notebook仪表板和Notebook Editor中的按钮触发.

I'm creating a custom front-end extension for Jupyter Notebook. The actions will be triggered via buttons in the Notebook Dashboard and the Notebook Editor.

该扩展名将影响单个或多个文件(例如已经存在的移动",重复"等-Button会这样做).因此,结果按钮可能看起来像这样:

The extension will affect single or multiple files (like the already existing "Move", "Duplicate", etc -Buttons do). So the resulting button might look like this:

由于

I can already place buttons in the tool-bar of the Notebook Editor, thanks to this tutorial, but I'm still unable to add actions to the toolbar in the Dashboard.

推荐答案

您可以使用一些jQuery来获得这种效果.例如,如果您希望按钮出现在删除"按钮之前,则可以添加

You can use a bit of jQuery to get this effect. For instance, if you want your button to appear before the Delete button, you can add something like

$('<button/>')
    .addClass('my-new-button btn btn-default btn-xs')
    .attr('title', 'My New Button')
    .attr('aria-label', 'My New Button')
    .text('My New Button')
    .insertBefore('.delete-button')
    .on('click', function () {...});

这有点脆弱,因为它依赖于'.delete-button'在该位置,但是文档指出前端API仍然不是很稳定.另外,该按钮可能始终会显示,因为我还没有找到访问selected列表并检查是否应该显示该按钮的方法.最后,这可能不适用于JupyterLab,后者是未来

This is a little fragile, because it relies on the '.delete-button' being in that location, but the docs note that the front-end API is not very stable anyways. In addition, the button will probably always be shown, since I haven't found a way to get access to the selected list and check whether the button should be displayed. Finally, this probably won't work with JupyterLab which is the future

这可能会出现nbextension(请参见前端扩展分发扩展名)以使其易于安装.

This could go in an nbextension (see frontend extensions and distributing extensions) to make it easier to install.

这篇关于如何在Jupyter Notebook仪表板的工具栏中添加操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆