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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy