McUtils.Jupyter
Defines a set of useful interactive tools for working in Jupyter (primarily JupterLab) environments
Members
Examples
Before we can run our examples we should get a bit of setup out of the way. Since these examples were harvested from the unit tests not all pieces will be necessary for all situations.
All tests are wrapped in a test class
class JupyterTests(TestCase):
HTML
def test_HTML(self):
Div = HTML.Div
Bootstrap.Panel(
Bootstrap.Grid(np.random.rand(5, 5).round(3).tolist()),
header='Test Panel',
variant='primary'
).tostring()
Styles
def test_Styles(self):
CSS.parse("""
a {
text-variant:none;
}
""")[0].tostring()
WidgetConstruction
def test_WidgetConstruction(self):
from Psience.Molecools import Molecule
water = Molecule.from_string('O', 'smi')
widg = interactive.JHTML.Div(water.plot(backend='x3d').figure.to_x3d(), dynamic=True)
print(widg.elem.children[0].children)
WidgetInteractivity
def test_WidgetInteractivity(self):
import McUtils.Jupyter as interactive
from Psience.Molecools import Molecule
reactant = Molecule.from_string("CCO", "smi")
p = reactant.plot(backend='x3d')
print(type(
interactive.Grid([[
p, p
]], dynamic=False).to_jhtml()
))
print(type(
interactive.Carousel([
p, p
], dynamic=False).to_jhtml()
))