Closed AndresOrtegaGuerrero closed 6 months ago
@AndresOrtegaGuerrero
I just found that direct file system access like this is not possible on standard web pages due to security constraints. In my notebook, when I run viewer.download_image('filename.png')
, it will download the image to the Download
folder directly without open a panel. So, you can write a loop and save your images with different names.
@superstar54 I tested in my notebook, in my folder it cant directly save the file. Also it only shows the panel if i display the viewer in the jupyter notebook.
Please try to change the browser settings to save downloads to their Downloads folder automatically. This could be different for different browsers.
I was working in visual studio
Hi @AndresOrtegaGuerrero , I tried to fix this issue since it is an important use case. Please use the latest version (0.0.11), or install the latest version from source, first clone the repository and then run:
cd weas-widget
npm install
npm run build
pip install -e .
Here is an example script:
from weas_widget import WeasWidget
from ase.io.cube import read_cube_data
volume, atoms = read_cube_data("./datas/h2o-homo.cube")
# use different camera position
for pos in [[0, 0, 100], [0, 100, 0]]:
viewer = WeasWidget()
viewer.from_ase(atoms)
viewer.volumetricData = {"values": volume}
viewer.isoSettings = [{"mode": 0}]
display(viewer)
name = "-".join([str(x) for x in pos])
viewer.save_image(f"/home/xing/h2o-homo-{name}.png",
camera_position = pos)
Hi @superstar54 I just tested it works!
It could be really useful to add a method that can export the figure given a path
as
viewer.export_image("/User/Document/Orbital/cube.png")