Search code examples
pythonimagepython-imaging-library

How do I take an image from online and make it pop up as a window when I run it so I can use the image as reference?


So I am making code that is simulating someone going to a store and buying stuff and they have a random amount of money from a wheel they spin and I want an image of the store layout to pop up on a window so the user can use that for reference when they want to see where they can go to buy things.

I tried to use something called Pillow, which I downloaded in the terminal, but I couldn't get it to work. The file name is called IC-Store-Layout-Loop.png.

[My code for the image to pop up so far]

from PIL import Image
Image.open('CSAP CREATE TASK/IC-Store-Layout-Loop.png')


Solution

  • Image.open opens the image file and returns an image object to you. It does not DISPLAY anything. Try this:

    from PIL import Image
    pic = Image.open('CSAP CREATE TASK/IC-Store-Layout-Loop.png')
    pic.show()