Write HTML#
Exporting an interactive NGLView 3D visualization as a standalone HTML file.
The function molsysmt.third_party.nglview.write_html() serializes an active NGLWidget viewer and its scene representations into a self-contained HTML file for sharing and web publishing.
Added in version 1.0.0.
API documentation
Follow this link for a detailed description of the input arguments, raised errors, and returned objects: molsysmt.third_party.nglview.write_html().
Basic usage#
Let’s export an NGLView visualization to an HTML file on disk:
import molsysmt as msm
import os
molsys = msm.convert(msm.systems['T4 lysozyme L99A']['181l.h5msm'], to_form='molsysmt.MolSys')
view = msm.convert(molsys, to_form='nglview.NGLWidget')
html_file = 'demo_scene.html'
msm.third_party.nglview.write_html(view, html_file)
print('HTML file written:', os.path.exists(html_file))
if os.path.exists(html_file):
os.remove(html_file)
HTML file written: True
See also
View: Interactive 3D visualization gateway with
molsysmt.basic.view().NGLWidget: Form adapter for NGLView widget instances.