nglviewer / nglview

Jupyter widget to interactively view molecular structures and trajectories
http://nglviewer.org/nglview/latest/
Other
822 stars 134 forks source link

Parameter setting before viewing (or how to change the default values?) #554

Closed yqshao closed 7 years ago

yqshao commented 7 years ago

Discription

Thanks first for the great widget, I tried to integrate it with ASE and it worked quit well. Here's some feature that I'm not very clear about. I tried to customize some settings for the view such as clipDepth ,quality..., however, setting the parameter only works if I excute it in the following cell, for example, this won't work:

import ase
import vasp
import nglview
model=ase.io.read('POSCAR')
view=nglview.show_ase(model)
view.clear_representations()
view.add_spacefill(radius_type='vdw',scale=0.7)
view.add_unitcell()
view.displayed=True
view.parameters = {"backgroundColor": "black"}
view

Therefore, it seems hard for me to 'generate' a desired widget. Correct me if I use the widget the wrong way, but is there any way to set a "default parameter" or change it befor a widget is shown?

Version report

python -c 'import nglview; print(nglview.__version__)'
0.6.2.1+11.gccbf561
python -c 'import ipywidgets; print(ipywidgets.__version__)'
5.2.2
python -c 'import traitlets; print(traitlets.__version__)'
4.3.1
hainm commented 7 years ago

hi,

that's the limitation of current implementation. We will fix that and ping you later. Thanks.

hainm commented 7 years ago

related to https://github.com/arose/nglview/issues/537

hainm commented 7 years ago

fixed in #555

Please give it a try.

parameters

yqshao commented 7 years ago

Cool, just exited to show how this could help in my workflow, and thanks again for this fix.

notebook

There might be some undesired behavior though, for example, when I used this combined layout, cell didn't show up in the first row. And the default orientation issue mentioned in #511. But I think the parameter setup is fine now.👍

hainm commented 7 years ago

cool. Feel free to make a PR for user example here