title: Display images one by one using Python PIL library
body: <p>I intend to show a list of images in a directory one by one using Python PIL(i.e close the previous image window before the next image window opens). Here is my code which doesn't seem to work . It opens images one after the other without closing the previous window.</p>
  
  <pre><code>def show_images(directory):
      for filename in os.listdir(directory):
          path = directory + "/" + filename
          im = Image.open(path)
          im.show()
          im.close()
          time.sleep(5)
  </code></pre>
  
  <p>Can anyone help me with this? I insist on using the PIL library.
  Thanks </p>