Skip to content

Commit 4d2a194

Browse files
authored
Merge pull request #245 from jcoady/jupyterlab4
Updated to support Jupyter Notebook 7
2 parents 4a9ed52 + 6acbfc7 commit 4d2a194

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

vpython/with_notebook.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ def find_free_port():
6868
pass
6969

7070

71-
if 'nbextensions' in os.listdir(jd):
71+
if ('nbextensions' in os.listdir(jd)) and (notebook.__version__ <= '6.5.5'):
7272
ldir = os.listdir(nbdir)
7373
if ('vpython_data' in ldir and len(os.listdir(nbdata)) == datacnt and
7474
'vpython_libraries' in ldir and len(os.listdir(nblib)) == libcnt and
7575
'vpython_version.txt' in ldir):
7676
v = open(nbdir+'/vpython_version.txt').read()
7777
transfer = (v != __version__) # need not transfer files to nbextensions if correct version's files already there
7878

79-
if transfer:
79+
if transfer and (notebook.__version__ <= '6.5.5'):
8080
notebook.nbextensions.install_nbextension(path = package_dir+"/vpython_data",overwrite = True,user = True,verbose = 0)
8181
notebook.nbextensions.install_nbextension(path = package_dir+"/vpython_libraries",overwrite = True,user = True,verbose = 0)
8282

@@ -98,15 +98,16 @@ def find_free_port():
9898
fd.write(__version__)
9999
fd.close()
100100

101-
display(Javascript("""if (typeof Jupyter !== "undefined") {require.undef("nbextensions/vpython_libraries/glow.min");}else{element.textContent = ' ';}"""))
102-
display(Javascript("""if (typeof Jupyter !== "undefined") {require.undef("nbextensions/vpython_libraries/glowcomm");}else{element.textContent = ' ';}"""))
103-
display(Javascript("""if (typeof Jupyter !== "undefined") {require.undef("nbextensions/vpython_libraries/jquery-ui.custom.min");}else{element.textContent = ' ';}"""))
101+
if ('nbextensions' in os.listdir(jd)) and (notebook.__version__ <= '6.5.5'):
102+
display(Javascript("""if (typeof Jupyter !== "undefined") {require.undef("nbextensions/vpython_libraries/glow.min");}else{element.textContent = ' ';}"""))
103+
display(Javascript("""if (typeof Jupyter !== "undefined") {require.undef("nbextensions/vpython_libraries/glowcomm");}else{element.textContent = ' ';}"""))
104+
display(Javascript("""if (typeof Jupyter !== "undefined") {require.undef("nbextensions/vpython_libraries/jquery-ui.custom.min");}else{element.textContent = ' ';}"""))
104105

105-
display(Javascript("""if (typeof Jupyter !== "undefined") {require(["nbextensions/vpython_libraries/glow.min"], function(){console.log("GLOW LOADED");});}else{element.textContent = ' ';}"""))
106-
display(Javascript("""if (typeof Jupyter !== "undefined") {require(["nbextensions/vpython_libraries/glowcomm"], function(){console.log("GLOWCOMM LOADED");});}else{element.textContent = ' ';}"""))
107-
display(Javascript("""if (typeof Jupyter !== "undefined") {require(["nbextensions/vpython_libraries/jquery-ui.custom.min"], function(){console.log("JQUERY LOADED");});}else{element.textContent = ' ';}"""))
106+
display(Javascript("""if (typeof Jupyter !== "undefined") {require(["nbextensions/vpython_libraries/glow.min"], function(){console.log("GLOW LOADED");});}else{element.textContent = ' ';}"""))
107+
display(Javascript("""if (typeof Jupyter !== "undefined") {require(["nbextensions/vpython_libraries/glowcomm"], function(){console.log("GLOWCOMM LOADED");});}else{element.textContent = ' ';}"""))
108+
display(Javascript("""if (typeof Jupyter !== "undefined") {require(["nbextensions/vpython_libraries/jquery-ui.custom.min"], function(){console.log("JQUERY LOADED");});}else{element.textContent = ' ';}"""))
108109

109-
if transfer:
110+
if transfer and (notebook.__version__ <= '6.5.5'):
110111
time.sleep(4) # allow some time for javascript code above to run after nbextensions update before attempting to setup Comm Channel
111112
else:
112113
time.sleep(2) # allow some time for javascript code above to run before attempting to setup Comm Channel

0 commit comments

Comments
 (0)