Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3312d5f

Browse files
author
minjk-bl
committed
Add toggle toolbar button for notebook7.x
1 parent04c1cb4 commit3312d5f

File tree

5 files changed

+76
-16
lines changed

5 files changed

+76
-16
lines changed

‎jupyterlab/lib/VpPanel.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ define([
88
'jquery-ui',
99
'jquery-ui-css',
1010
'codemirror/lib/codemirror',
11-
// __VP_CSS_LOADER__('codemirror/lib/codemirror'), // INTEGRATION: unified version of css loader
11+
'vp_base/lib/codemirror/lib/codemirror.css',// INTEGRATION: unified version of css loader
1212
'vp_base/js/loadVisualpython',
1313
'vp_base/js/com/com_Config'
1414
],function(
@@ -17,7 +17,7 @@ define([
1717
text,css,$,
1818
ui,uiCss,
1919
codemirror,
20-
//cmCss,
20+
cmCss,
2121
loadVisualpython,com_Config){
2222

2323
const{
@@ -41,9 +41,9 @@ define([
4141
this.app=app;
4242
this.vpFrame=loadVisualpython.initVisualpython();
4343

44-
this.id='visualpython_vpPanel';
44+
this.id='jupyterlab-visualpython:panel';
4545
// LabIcon with svg :@jupyterlab/ui-components/lib/icon/labicon.js
46-
this.title.icon=newLabIcon({name:'visualpython:toggle',svgstr:vpIcon.default});
46+
this.title.icon=newLabIcon({name:'jupyterlab-visualpython:toggle-icon',svgstr:vpIcon});
4747
this.title.caption='Visual Python';
4848

4949
// register node using jquery to element

‎jupyterlab/lib/index.js‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ global.__VP_RAW_LOADER__ = function(path) {
1414
returnpath;
1515
}
1616

17+
constvpId='jupyterlab-visualpython:plugin';
18+
19+
const{ ICommandPalette}=require('@jupyterlab/apputils');
20+
1721
global.$=$;
1822
global.vpBase=path.resolve(__dirname,"lib")+'/';
1923
module.exports=[{
20-
id:'visualpython:entry',
24+
id:vpId,
2125
autoStart:true,
22-
activate:function(app){
26+
requires:[ICommandPalette],
27+
activate:function(app,palette){
2328
console.log(
2429
'JupyterLab extension visualpython is activated!'
2530
);
@@ -35,5 +40,30 @@ module.exports = [{
3540
// Add vp to the right area:
3641
varvpPanel=newVpPanel(app);
3742
app.shell.add(vpPanel,'right',{rank:900,type:'Visual Python'});
43+
44+
// Add toggle button
45+
letisVpVisible=app.name!=='JupyterLab';// compatible for notebook 7.x (hidden for jupyterlab)
46+
lettoggleCommand='jupyterlab-visualpython:toggle-panel';
47+
letvpLabel=isVpVisible?'Toggle Visual Python':'';
48+
app.commands.addCommand(toggleCommand,{
49+
isEnabled:()=>isVpVisible,
50+
isVisible:()=>isVpVisible,
51+
iconClass:'jp-vp-icon',
52+
iconLabel:vpLabel,
53+
execute:()=>{
54+
if(app.shell.rightCollapsed===true||$('#vp_wrapper').is(':visible')===false){
55+
app.shell.activateById('vp_wrapper');
56+
}else{
57+
app.shell.collapseRight();
58+
}
59+
}
60+
});
61+
62+
// Add command palette
63+
palette.addItem({
64+
command:toggleCommand,
65+
category:'Visual Python',
66+
label:'Toggle Visual Python'
67+
});
3868
}
3969
}];

‎jupyterlab/schema/plugin.json‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"jupyter.lab.toolbars": {
3+
"Notebook": [
4+
{
5+
"name":"show-visualpython",
6+
"command":"jupyterlab-visualpython:toggle-panel"
7+
}
8+
]
9+
},
10+
"jupyter.lab.shortcuts": [
11+
{
12+
"command":"jupyterlab-visualpython:toggle-panel",
13+
"keys": ["Accel Shift V"],
14+
"selector":"body"
15+
}
16+
],
17+
"title":"jupyterlab-visualpython",
18+
"description":"jupyterlab-visualpython plugin",
19+
"type":"object",
20+
"properties": {},
21+
"additionalProperties":false
22+
}

‎jupyterlab/style/base.css‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.jp-vp-icon {
2+
background-image:url('./icon.svg');
3+
}
4+
/* lm-mod-hidden is not on appropriate tag when isVisible is false */
5+
.lm-mod-hidden[data-command="jupyterlab-visualpython:toggle-panel"] {
6+
display: none!important;
7+
cursor: default;
8+
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
try:
2+
from ._versionimport__version__
3+
exceptImportError:
4+
# Fallback when using the package in dev mode without installing
5+
# in editable mode with pip. It is highly recommended to install
6+
# the package from a stable release or in editable mode: https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs
7+
importwarnings
8+
warnings.warn("Importing 'jupyterlab-visualpython' outside a proper installation.")
9+
__version__="dev"
110

2-
importjson
3-
frompathlibimportPath
4-
5-
from ._versionimport__version__
6-
7-
HERE=Path(__file__).parent.resolve()
8-
9-
with (HERE/"labextension"/"package.json").open()asfid:
10-
data=json.load(fid)
1111

1212
def_jupyter_labextension_paths():
1313
return [{
1414
"src":"labextension",
15-
"dest":data["name"]
15+
"dest":"jupyterlab-visualpython"
1616
}]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp