Python HELP ?!

ben52646

Distinguished
May 22, 2010
14
0
18,560
0
I am very new to python. How do I located a file on my computer (Mac) in a python program. Here is the program I am trying to run (I know its not done yet):

bif="bg.jpg"
mif="ball.png"

import pygame, sys
from pygame.locals import *

pygame.init()
screen=pygame.display.set_mode
((420,280),0,32)

backround=
pygame.image.load(bif).convert()

mouse_c=
pygame.image.load(mif).convert_alpha()

while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()

screen.blit(backround, (0,0))


This is the error I get when I try to run it:

Traceback (most recent call last):
File "/Users/Ben/Desktop/Python/Game", line 10,
in
backround=pygame.image.load(bif).convert()
error: Couldn't open bg.jpg


How to put in the location (on my computer) for "bif" and "mif"?

Keep in mind I am using a mac.


Thanks,
Ben
 

kyeana

Distinguished
May 21, 2008
230
0
18,860
7
I think you could do the full link to those files and have it work, something along the lines of

bif="/home/username/pictures/bg.jpg"

(Not sure if that is how the filepaths look for macs, as i don't own one. It is valid for linux though, so mac is probably failry similar)

Good luck
 
Thread starter Similar threads Forum Replies Date
A Apps General Discussion 5
T Apps General Discussion 5
A Apps General Discussion 4
A Apps General Discussion 4
A Apps General Discussion 1
R Apps General Discussion 1
M Apps General Discussion 1
A Apps General Discussion 1
H Apps General Discussion 1
G Apps General Discussion 5
M Apps General Discussion 11
A Apps General Discussion 6
G Apps General Discussion 19
C Apps General Discussion 1
Jaakey Apps General Discussion 2
T Apps General Discussion 3
B Apps General Discussion 4
R Apps General Discussion 1
D Apps General Discussion 6
G Apps General Discussion 3

ASK THE COMMUNITY