Answers.Body: <p>try:</p>
  <pre><code>
  import time
  
  def trial(pathname, num_files):
      for i in range(num_files):
          filename = (pathname + str(i + 1)  +'.pdb')
          print(filename)
          # print(i)
          cmd.load(filename, (i+1))
          
          cmd.sync(timeout=2000 , poll=2.0) ### ***
  
          time.sleep(4)
  
          cmd.hide()
  </code></pre>
  <p>***See <a href="https://pymolwiki.org/index.php/Sync" rel="nofollow noreferrer">cmd.sync(timeout: float = 1.0, poll: float = 0.05)</a></p>
  <blockquote>
  <p>sync is an API-only function which waits until all current commands have been executed before returning. A timeout can be used to insure that this command eventually returns.</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-06-10T19:48:07.320Z
Answers.LastActivityDate: 2024-06-10T20:15:46.650Z
Answers.LastEditDate: 2024-06-10T20:15:46.650Z
Answers.UserDisplayName: pippo1980
Body: <p>I have a sequence of pdb files which I want to load in pymol window so that it gives an impression of a video. I am using cmd.load function in a loop and deleting the loaded file in the next step. But for some reason the window pauses until all iteration steps have been completed and giving nothing else in the end. I know that the files are loaded because without the “delete” line I can find all pdbs overlapped on one another. Any suggestions? Thanks and regards</p>
  <pre><code>def trial(pathname, num_files):
      for i in range(num_files):
          filename = (pathname + str(i + 1)  +'.pdb')
          print(filename)
          # print(i)
          cmd.load(filename, (i+1))
          cmd.hide()
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-12-07T15:05:19.833Z
Comments.Text: https://pymolwiki.org/index.php/Frame is the way —you are after moviemaking which is rich in tutorials, so I am just leaving the link here. Hopefully a tutorial about working with Frames with answer your Q.
Comments.UserDisplayName: Matteo Ferla
Tags: <python><pymol>
Title: Visualise multiple disappearing pdb files in Pymol
ThreadText: # Visualise multiple disappearing pdb files in Pymol
  
  (Asked by: username_0 on 2022-12-05)
  
  I have a sequence of pdb files which I want to load in pymol window so that it gives an impression of a video. I am using cmd.load function in a loop and deleting the loaded file in the next step. But for some reason the window pauses until all iteration steps have been completed and giving nothing else in the end. I know that the files are loaded because without the “delete” line I can find all pdbs overlapped on one another. Any suggestions? Thanks and regards
  
  ```
  def trial(pathname, num_files):
      for i in range(num_files):
          filename = (pathname + str(i + 1)  +'.pdb')
          print(filename)
          # print(i)
          cmd.load(filename, (i+1))
          cmd.hide()
  
  ```
  
  **Tags:** python, pymol
  
  > **Comments:**
  > **username_1**: https://pymolwiki.org/index.php/Frame is the way —you are after moviemaking which is rich in tutorials, so I am just leaving the link here. Hopefully a tutorial about working with Frames with answer your Q.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2024-06-10. Score: 0
  
  try:
  
  ```
  
  import time
  
  def trial(pathname, num_files):
      for i in range(num_files):
          filename = (pathname + str(i + 1)  +'.pdb')
          print(filename)
          # print(i)
          cmd.load(filename, (i+1))
          
          cmd.sync(timeout=2000 , poll=2.0) ### ***
  
          time.sleep(4)
  
          cmd.hide()
  
  ```
  
  \*\*\*See [cmd.sync(timeout: float = 1.0, poll: float = 0.05)](https://pymolwiki.org/index.php/Sync)
  
  > sync is an API-only function which waits until all current commands have been executed before returning. A timeout can be used to insure that this command eventually returns.
  
  
  ---
  
  