Pygame uploading file images

Pygame uploading file images
0
#1

hi I am learning pygame please.I am using windows computer.Please I want to upload images from opengameart.org.
I have downloaded them for my game.Please see the error that comes in my pygame.Please help me with this.
Many thanks

#2

hi, please see the codes that i have written in IDLE shell of pygame…many thanks

#3

I’d try checking your img_dir variable. Kinda seems like it might be pointing to the image file ship1.jpg rather than the folder project1.
The path it’s trying to open refers to the JPG twice: ...\Documents\project1\ship1.jpg\ship1.jpg

1 Like
#4

4 error3

hi please have a look.I have changed it but its still the same thing…please help!

#5

It looks like you’re repeating project1 as part of your path.

Perhaps you just want img_dir = path.dirname(__file__) instead. What does your directory structure look like?

#6

hi, when i write the code as you have said…after running the code it says invalid syntax.please see as attached.syntax

#7

You’re missing a parenthesis, but you no longer need the path.join. Just write it as

img_dir = path.dirname(__file__)

That is, assuming your images do actually live one directory up from where your file is – I don’t know what your directory structure looks like.

#8

#9

I have saved the image i am trying to upload with the name as above

#10