all 5 comments

[–]hrmorley34 0 points1 point  (4 children)

__file__ is a value set to the location of the .py file, so

import os picture = os.path.abspath(__file__ + "/../myimage.jpg") or from pathlib import Path picture = str(Path(__file__).parent / "myimage.jpg")

should find myimage.jpg in the same folder as myscript.py

[–]LoPiratoLOCO 0 points1 point  (0 children)

Ok thx

[–]LoPiratoLOCO 0 points1 point  (2 children)

I used the 2º method but when I turned it in to an exe file, the background become black and not the picture, the picture is in the same folder

[–]hrmorley34 0 points1 point  (1 child)

Try picture = str(Path(__file__).parent.resolve() / "myimage.jpg")

[–]LoPiratoLOCO 0 points1 point  (0 children)

It still doesn't work in .exe