Skip to content

One file program using custom PNG images #18

Answered by Akascape
nekoalin asked this question in Q&A
Discussion options

You must be logged in to vote

@nekoalin You should change the location search method.
I guess you are finding assets like this: C:/some_folder/.../image.png
This is not a good way to search files because the location may not exist in other computers.

So you should change the method for searching files.
For example, this is your folder structure:

‣ folder
   ↳image.png
‣ program.py

Inside program.py:
‣ simple way to search that asset:

asset = "folder/image.png"

‣ best way to search the asset:

import os
base_path = os.path.dirname(os.path.realpath(__file__))
asset = os.path.join(base_path, "folder", "image.png")

You should use this method to search files and images and it will never give errors.

Secondly, if you are ma…

Replies: 2 comments 21 replies

Comment options

You must be logged in to vote
18 replies
@nekoalin
Comment options

@Akascape
Comment options

@nekoalin
Comment options

@Akascape
Comment options

@nekoalin
Comment options

Answer selected by Akascape
Comment options

You must be logged in to vote
3 replies
@nekoalin
Comment options

@Akascape
Comment options

@nekoalin
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
documentation Improvements or additions to documentation
2 participants