Skip to content

Commit

Permalink
Merge pull request #63 from coltonbh/feature-interval
Browse files Browse the repository at this point in the history
  • Loading branch information
coltonbh authored Oct 1, 2024
2 parents ab0b7b4 + 69263a5 commit c6d5667
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [unreleased]

###

- `interval` to view animations. Sets the interval between frames in milliseconds. Defaults to 100.

## [0.11.12] - 2024-10-01

### Added
Expand Down
5 changes: 4 additions & 1 deletion qcio/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def generate_structure_viewer_html(
show_indices: bool = False,
same_viewer: bool = False,
view_2d: bool = False,
interval: int = 100,
) -> str:
"""
Generate the core HTML viewer for a Structure or list of Structures using py3Dmol
Expand All @@ -109,6 +110,7 @@ def generate_structure_viewer_html(
dictionary for AtomStyleSpec <https://3dmol.org/doc/AtomStyleSpec.html>
show_indices: Whether to show the atom indices in the viewer.
view_2d: Whether to display the structure in 2D (PNG images).
interval: The interval in milliseconds for the animation.
Returns:
str: The HTML string for the viewer.
Expand Down Expand Up @@ -193,7 +195,8 @@ def generate_structure_viewer_html(
if isinstance(struct, list): # Animate lists of structures
combined_xyz = "".join(s.to_xyz() for s in struct)
viewer.addModelsAsFrames(combined_xyz, "xyz", viewer=grid)
viewer.animate({"loop": "forward"}, viewer=grid)
viewer.animate({"loop": "forward", "interval": interval}, viewer=grid)
# viewer.animate({"loop": "forward"}, viewer=grid)
else:
viewer.addModel(struct.to_xyz(), "xyz", viewer=grid)

Expand Down

0 comments on commit c6d5667

Please sign in to comment.