<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>

CC BY-SA 4.0
2024-06-10T19:48:07.320Z
2024-06-10T20:15:46.650Z
2024-06-10T20:15:46.650Z
pippo1980
<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>

CC BY-SA 4.0
2022-12-07T15:05:19.833Z
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.
Matteo Ferla
<python><pymol>
Visualise multiple disappearing pdb files in Pymol
# 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)

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.


---

