Sean LaFata
Sean LaFata

Reputation: 1

Opening an image using basic python commands

So I'm creating a basic program that lets you play roulette for a Computer Science Class. The program is fully built, I just had a question regarding images in Python. Is is possible to have my program display an image when prompted to by an if statement? I'm fairly new to python, any help would be appreciated.

Upvotes: 0

Views: 105

Answers (2)

Jefferson Silva
Jefferson Silva

Reputation: 51

from PIL import Image

image = Image.open('path_to_image')
image.load()

Here is a tutorial on how to use Pil(low), a Python Image Library: How to use Pillow

Edit: You are probably building a GUI for you game, so check out TKinter, it's Graphical User Interface Library, with this you can create the "windows" of your game and place images and buttons there.

Upvotes: 1

f.rodrigues
f.rodrigues

Reputation: 3587

Use Python Image Library(PIL), it's pretty easy and has tons of documentation.

Upvotes: 0

Related Questions