Picture files in programs

Picture files in programs

Postby Likeawhisper » Fri Jul 12, 2013 3:32 am

Hi forum,

I've decided to create a small, basic program that basically asks through a string input for a president of the USA, and if (for example) "George Bush" is typed in, it displays Bush's picture. I've got all the picture file names and the basic code, but I don't know how to make the picture put itself into the code. I don't know what command or function will let you display a picture. I tried copying off someone else's program, and I implemented his method into my code. But whenever I run the program to test Washington, it has an error and says something like file:gwashington.jpg not found" or something.

How do I make it identify file gwashington? I had all these plans to make games like snake and pong, but I need to use file images and now all my dreams have been crushed. :(. Some help?

Likeawhisper
Likeawhisper
 
Posts: 2
Joined: Wed Jul 10, 2013 8:42 am

Re: Picture files in programs

Postby Mekire » Fri Jul 12, 2013 4:22 am

If you want to show a picture as the result of a raw_input you could try PIL.
There are some issues with doing this in windows7 though as the image returns before it is displayed.
If this applies to you, try the webbrowser module instead (the following won't actually open a webbrowser);
Code: Select all
import webbrowser
webbrowser.open('image.png')

Your program will obviously have to be told where your computer can find the image.

If you want to make basic games start looking at pygame code.

Anyway, post your code; tell us where your image is located; then we can better assist.

-Mek
User avatar
Mekire
 
Posts: 979
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan


Return to Game Development

Who is online

Users browsing this forum: No registered users and 2 guests