Skip to content

Commit

Permalink
Merge pull request #245 from jcoady/jupyterlab4
Browse files Browse the repository at this point in the history
Updated to support Jupyter Notebook 7
  • Loading branch information
jcoady committed Oct 31, 2023
2 parents 4a9ed52 + 6acbfc7 commit 4d2a194
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions vpython/with_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ def find_free_port():
pass


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

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

Expand All @@ -98,15 +98,16 @@ def find_free_port():
fd.write(__version__)
fd.close()

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

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

if transfer:
if transfer and (notebook.__version__ <= '6.5.5'):
time.sleep(4) # allow some time for javascript code above to run after nbextensions update before attempting to setup Comm Channel
else:
time.sleep(2) # allow some time for javascript code above to run before attempting to setup Comm Channel
Expand Down

0 comments on commit 4d2a194

Please sign in to comment.