py3Dmol 2.0.4__tar.gz → 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py3Dmol
3
- Version: 2.0.4
3
+ Version: 2.2.0
4
4
  Summary: An IPython interface for embedding 3Dmol.js views in Jupyter notebooks
5
5
  Home-page: https://3dmol.org
6
6
  Author: David Koes
@@ -44,12 +44,6 @@ From PyPI:
44
44
  pip install py3Dmol
45
45
 
46
46
 
47
- *Important:* In order to use with JupyterLab you must install the JupyterLab extension:
48
-
49
- jupyter labextension install jupyterlab_3dmol
50
-
51
-
52
-
53
47
  Usage
54
48
  -----
55
49
 
@@ -23,12 +23,6 @@ From PyPI:
23
23
  pip install py3Dmol
24
24
 
25
25
 
26
- *Important:* In order to use with JupyterLab you must install the JupyterLab extension:
27
-
28
- jupyter labextension install jupyterlab_3dmol
29
-
30
-
31
-
32
26
  Usage
33
27
  -----
34
28
 
@@ -54,13 +54,14 @@ class view(object):
54
54
  the exception that the functions all return None.
55
55
  http://3dmol.org/doc/GLViewer.html
56
56
  '''
57
- def __init__(self,query='',width=640,height=480,viewergrid=None,data=None,style=None,linked=True,options=dict(),js='https://cdnjs.cloudflare.com/ajax/libs/3Dmol/2.0.4/3Dmol-min.js'):
57
+ def __init__(self,query='',width=640,height=480,viewergrid=None,data=None,style=None,linked=True,options=dict(),format=None,js='https://cdnjs.cloudflare.com/ajax/libs/3Dmol/2.2.0/3Dmol-min.js'):
58
58
  '''Create a 3Dmol.js view.
59
59
  width -- width in pixels of container
60
60
  height -- height in pixels of container
61
61
  query -- optional argument to provide to $3Dmol.download
62
62
  viewergrid -- optional tuple (rows,columns) to define grid
63
- data -- molecular data to provide to addModel, wit viewer grid can be indexed (r,c)
63
+ data -- molecular data to provide to addModel, with viewer grid can be indexed (r,c)
64
+ format -- format of provided data
64
65
  style -- style to apply, with viewer grid can be indexed (r,c)
65
66
  options -- optional options to provide to $3Dmol.download
66
67
  js -- url for 3Dmol.js'''
@@ -73,8 +74,7 @@ class view(object):
73
74
  if type(height) == int:
74
75
  height = '%dpx'%height
75
76
  self.startjs = '''<div id="%s" style="position: relative; width: %s; height: %s;">
76
- <p id="%s" style="background-color:#ffcccc;color:black">You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension: <br>
77
- <tt>jupyter labextension install jupyterlab_3dmol</tt></p>
77
+ <p id="%s" style="background-color:#ffcccc;color:black">3Dmol.js failed to load for some reason. Please check your browser console for error messages.<br></p>
78
78
  </div>\n''' % (divid,width,height,warnid)
79
79
  self.startjs += '<script>\n'
80
80
  self.endjs = '</script>'
@@ -146,10 +146,20 @@ if(warn) {
146
146
  cmds = ''
147
147
  if data:
148
148
  try:
149
- d = data[r][c]
149
+ if type(data) == str:
150
+ d = data
151
+ else:
152
+ d = data[r][c]
150
153
  except:
151
154
  d = data
152
- self.startjs += "viewergrid_UNIQUEID[%d][%d].addModel(%s);\n"%(r,c,json.dumps(d))
155
+ try:
156
+ if type(format) == str:
157
+ f = format
158
+ else:
159
+ f = format[r][c]
160
+ except:
161
+ f = format
162
+ self.startjs += f"viewergrid_UNIQUEID[{r}][{c}].addModel({json.dumps(d)}{','+json.dumps(f) if f else ''});\n"
153
163
  if style:
154
164
  try:
155
165
  s = style[r][c]
@@ -161,7 +171,7 @@ if(warn) {
161
171
  else:
162
172
  cmds = ''
163
173
  if data:
164
- cmds = "viewer_UNIQUEID.addModel(%s);\n"%json.dumps(data)
174
+ cmds = f"viewer_UNIQUEID.addModel({json.dumps(data)}{','+json.dumps(format) if format else ''});\n"
165
175
  if style:
166
176
  cmds += "viewer_UNIQUEID.setStyle(%s);\n"%json.dumps(style)
167
177
  self.startjs += cmds + "viewer_UNIQUEID.zoomTo();\n"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py3Dmol
3
- Version: 2.0.4
3
+ Version: 2.2.0
4
4
  Summary: An IPython interface for embedding 3Dmol.js views in Jupyter notebooks
5
5
  Home-page: https://3dmol.org
6
6
  Author: David Koes
@@ -44,12 +44,6 @@ From PyPI:
44
44
  pip install py3Dmol
45
45
 
46
46
 
47
- *Important:* In order to use with JupyterLab you must install the JupyterLab extension:
48
-
49
- jupyter labextension install jupyterlab_3dmol
50
-
51
-
52
-
53
47
  Usage
54
48
  -----
55
49
 
@@ -24,7 +24,7 @@ setup(
24
24
  # the version across setup.py and the project code, see
25
25
  # https://packaging.python.org/en/latest/single_source_version.html
26
26
  # Keep version in synce with 3Dmol.js version. Use "postX" suffix if needed
27
- version='2.0.4',
27
+ version='2.2.0',
28
28
 
29
29
  description='An IPython interface for embedding 3Dmol.js views in Jupyter notebooks',
30
30
  long_description=long_description,
File without changes
File without changes
File without changes