Displaying IPython Widgets


#1

I am using the Python package nglview to create a visualisation. The object it generates is a PyObject <nglview.widget.NGLWidget ...> and looking at the source-code of nglview this is a subclass of ipywidgets.DOMWidget. When trying to display it using

@pyimport nglview as nv
@pyimport IPython.display as ipydisp
ipydisp.display(nv.show_ase(si)). #  `si` is a `PyObject` which can be visualised using nglview

This generates the error message

Widget Javascript not detected.  It may not be installed or enabled properly.

The same code works fine from a Python notebook. Can anybody advise?

I am trying to put together a MWE (the current example requires a lot of dependencies) and will post it here if I succeed.


#2

A MWE - requires nglview which can be installed via

pip install nglview
jupyter-nbextension enable nglview --py --sys-prefix

In Python:

import nglview as nv
view = nv.show_pdbid("1l2y")
view

In Julia:

using PyCall
@pyimport nglview as nv
@pyimport IPython.display as ipydisp
view = nv.show_pdbid("1l2y")
ipydisp.display(view)

#3

Not supported by PyCall yet:

https://github.com/JuliaPy/PyCall.jl/issues/89

In principle it is possible, but no one has gotten around to implementing it.