-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting play to true in NGL trajectory viewer by default #1041
Comments
hi @Taylor-96 Please adapt below code. It should reply to two of your questions: import nglview as nv
from nglview import SimpletrajTrajectory
traj = SimpletrajTrajectory(nv.datafiles.XTC, nv.datafiles.PDB)
view = nv.show_simpletraj(traj)
stop = False
def loop(view):
import time
def do():
while True and not stop:
if view.frame == view.max_frame:
view.frame = 0
view.frame = view.frame + 1
time.sleep(0.2)
view._run_on_another_thread(do)
view.on_displayed(loop)
view To stop, just Cheers |
Hi, thanks a lot - that works great. I was just wondering if there is a way to access the values/status of the play button and loop button so that it is possible for the user to stop the animation by pressing the play button rather than manually putting stop=True in another cell? Thanks again! |
I don't know a solution on top of my head. You can access to the player via https://github.com/nglviewer/nglview/blob/master/nglview/widget.py#L300-L303 |
Hi, thanks a lot for the suggestion and for the help with this problem. I'll look into using this to update the status of the player then. Best wishes, Taylor |
Hello,
I was wondering if it is possible to have the animation of a trajectory shown in an NGL viewer set to play by default rather than requiring the user to press play first? On a similar note, would it also be possible to have looping set to true by default at initialization of the viewer? Cheers!
The text was updated successfully, but these errors were encountered: