How can I close an image shown to the user with the Python Imaging Library?

后端 未结 3 1620
暗喜
暗喜 2020-12-17 16:20

I have several images which I would like to show the user with Python. The user should enter some description and then the next image should be shown.

This is my cod

3条回答
  •  暖寄归人
    2020-12-17 16:50

    I've modified this recipe before to do some image work in Python. It uses Tkinter, so it doesn't require any modules besides PIL.

    '''This will simply go through each file in the current directory and
    try to display it. If the file is not an image then it will be skipped.
    Click on the image display window to go to the next image.
    
    Noah Spurrier 2007'''
    import os, sys
    import Tkinter
    import Image, ImageTk
    
    def button_click_exit_mainloop (event):
        event.widget.quit() # this will cause mainloop to unblock.
    
    root = Tkinter.Tk()
    root.bind("

提交回复
热议问题