made assets work independently from the working dir
This commit is contained in:
12
assets.py
12
assets.py
@ -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"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user