Skip to content

Commit 7fb067c

Browse files
committed
more
1 parent 9d259ea commit 7fb067c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

nglview/widget_molstar.py

+23
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
Unicode, observe)
66
from ._frontend import __frontend_version__
77
from .widget_base import WidgetBase
8+
from .utils.py_utils import (FileManager, _camelize_dict, _update_url,
9+
encode_base64, get_repr_names_from_dict,
10+
seq_to_string)
811

912

1013

@@ -81,3 +84,23 @@ def _on_frame_changed(self, change):
8184
"""set and send coordinates at current frame
8285
"""
8386
self._set_coordinates(self.frame)
87+
88+
def add_representation(self, **params):
89+
params = _camelize_dict(params)
90+
91+
if 'component' in params:
92+
model_index = params.pop('component')
93+
else:
94+
model_index = 0
95+
96+
for k, v in params.items():
97+
try:
98+
params[k] = v.strip()
99+
except AttributeError:
100+
# e.g.: opacity=0.4
101+
params[k] = v
102+
103+
self._remote_call('addRepresentation',
104+
args=[
105+
params, model_index
106+
])

0 commit comments

Comments
 (0)