How do I display and close an image with Python?

后端 未结 5 709
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 04:08

I would like to display an image with Python and close it after user enters the name of the image in terminal. I use PIL to display image, here is the code:

         


        
5条回答
  •  春和景丽
    2021-01-12 04:30

    Just open any image viewer/editor in a separate process and kill it once user has answered your question e.g.

    from PIL import Image
    import subprocess
    
    p = subprocess.Popen(["display", "/tmp/test.png"])
    raw_input("Give a name for image:")
    p.kill()
    

提交回复
热议问题