made assets work independently from the working dir

This commit is contained in:
2022-12-15 18:16:13 +01:00
parent 13e71697d7
commit af28b8fe4a

View File

@ -1,12 +1,18 @@
import os.path
from PyQt5.QtGui import QIcon, QPixmap from PyQt5.QtGui import QIcon, QPixmap
def get_asset(name):
dname = os.path.dirname(__file__)
return os.path.join(dname, "assets", name)
# These are function in order not to trigger: # These are function in order not to trigger:
# Must construct a QGuiApplication before a QPixmap # Must construct a QGuiApplication before a QPixmap
logo = lambda: QPixmap("assets/logo.png") logo = lambda: QPixmap(get_asset("logo.png"))
icon = lambda: QIcon("assets/icon.png") icon = lambda: QIcon(get_asset("icon.png"))
char = lambda: QIcon("assets/char.png") char = lambda: QIcon(get_asset("char.png"))