How do I display and close an image with Python?

后端 未结 5 722
佛祖请我去吃肉
佛祖请我去吃肉 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:32

    Not all GUIs are difficult to use.

    Here is a single-line solution using PySimpleGUI. Normally I wouldn't write it as a single line, but since it's a one-off, perhaps doesn't need adding to, then it's OK to do.

    import PySimpleGUI as sg
    
    sg.Window('My window').Layout([[ sg.Image('PySimpleGUI.png') ]]).Read()
    

提交回复
热议问题