I'm using auto-py-to-exe which is based on pyinstaller, trying to make an executable with --onefile, using pystray to make a tray app, but after compiling I get an error that the icon file cannot be found. See that in the code I tried to use os.path to get the most specific path possible, even so it is not possible to find.
The question is, how to make this path correct using --onfile?
import pystray
from PIL import Image
# ==============================
from os.path import join
from os import getcwd
TilleTables = SetInterval(1, TileTables)
# print(join(getcwd(), 'icon.png'))
menuImg = Image.open(join(getcwd(), 'icon.png'))
MenuIcon = pystray.Icon('Neural', menuImg, menu=pystray.Menu(
pystray.MenuItem('Exit', HandleTrayClick),
))
MenuIcon.run()
Traceback (most recent call last):
File "main.py", line 20, in <module>
File "PIL\Image.py", line 3092, in open
FileNotFoundError: [Errno 2] No such file or directory: 'icon.png'