superstar54 / weas-widget

A widget to visualize and edit atomic structures in Jupyter Notebook

Home Page:https://weas-widget.readthedocs.io/en/latest/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Set the attribute when initializing the viewer, does not work.

superstar54 opened this issue · comments

Set the attribute when initializing the viewer, does not work.

from ase.build import molecule
from weas_widget import WeasWidget
atoms = molecule("C2H6SO")
viewer = WeasWidget()
viewer.from_ase(atoms)
# this line does not work
viewer.modelStyle = 1
viewer

However, it does work when run later in another cell

viewer.modelStyle = 2

I may find the reason. Before the jupyter-notebook creates and shows the widget, one cannot modify its attributes because there is no (viewer) HTML element, and thus no EventListener, which is used to communicate between javascript and Python.