Aug-07-2022, 08:05 AM
(This post was last modified: Aug-07-2022, 08:18 AM by Gribouillis.)
(Aug-07-2022, 07:25 AM)Tomi Wrote: The icon.ico is in the same folder as the script im trying to run.Python will use the path relative to the current working directory, not the directory containing the script. Two solutions:
- Hard code the full path to the file, such as "/spam/eggs/icon.ico"
- Have the code compute the full path like in the below example
from pathlib import Path this_dir = Path(__file__).resolve().parent icon_ico = str(this_dir / 'icon.ico')If you want to distribute the program as a Python module, another option is to use package data files.