diff --git a/beeref/assets/__init__.py b/beeref/assets/__init__.py index 2778317..2507233 100644 --- a/beeref/assets/__init__.py +++ b/beeref/assets/__init__.py @@ -15,8 +15,8 @@ # You should have received a copy of the GNU General Public License # along with BeeRef. If not, see . +from importlib.resources import files as rsc_files import logging -import os.path from PyQt6 import QtGui, QtWidgets @@ -26,7 +26,7 @@ logger = logging.getLogger(__name__) class BeeAssets: _instance = None - PATH = os.path.dirname(__file__) + PATH = rsc_files('beeref.assets') def __new__(cls, *args, **kwargs): if not cls._instance: @@ -37,7 +37,7 @@ class BeeAssets: def on_new(self): logger.debug(f'Assets path: {self.PATH}') - self.logo = QtGui.QIcon(os.path.join(self.PATH, 'logo.png')) + self.logo = QtGui.QIcon(str(self.PATH.joinpath('logo.png'))) assert self.logo.isNull() is False self.cursor_rotate = self.cursor_from_image( 'cursor_rotate.png', (20, 20)) @@ -49,7 +49,7 @@ class BeeAssets: def cursor_from_image(self, filename, hotspot): app = QtWidgets.QApplication.instance() scaling = app.primaryScreen().devicePixelRatio() - img = QtGui.QImage(os.path.join(self.PATH, filename)) + img = QtGui.QImage(str(self.PATH.joinpath(filename))) assert img.isNull() is False pixmap = QtGui.QPixmap.fromImage(img) pixmap.setDevicePixelRatio(scaling) diff --git a/beeref/widgets/__init__.py b/beeref/widgets/__init__.py index 9000487..a5d0b4f 100644 --- a/beeref/widgets/__init__.py +++ b/beeref/widgets/__init__.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with BeeRef. If not, see . +from importlib.resources import files as rsc_files import logging -import os.path from PyQt6 import QtCore, QtWidgets, QtGui from PyQt6.QtCore import Qt @@ -66,14 +66,12 @@ class HelpDialog(QtWidgets.QDialog): def __init__(self, parent): super().__init__(parent) self.setWindowTitle(f'{constants.APPNAME} Help') - docdir = os.path.join(os.path.dirname(__file__), - '..', - 'documentation') + tabs = QtWidgets.QTabWidget() # Controls - with open(os.path.join(docdir, 'controls.html')) as f: - controls_txt = f.read() + controls_txt = rsc_files( + 'beeref.documentation').joinpath('controls.html').read_text() controls_label = QtWidgets.QLabel(controls_txt) controls_label.setTextInteractionFlags( Qt.TextInteractionFlag.TextSelectableByMouse) diff --git a/setup.cfg b/setup.cfg index 0605e76..0d0d247 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,8 @@ [flake8] -exclude = squashfs-root +exclude = + squashfs-root + build + dist [coverage:run] source = beeref