Fix ui import

This commit is contained in:
Fergal Moran
2021-08-04 23:23:43 +01:00
parent 10fcfdfb60
commit 166b11c616
3 changed files with 17 additions and 1 deletions

1
.gitignore vendored
View File

@@ -141,3 +141,4 @@ cython_debug/
.vscode/
working/
/src/disco_hue/desktop/ui/main_window.py
src/disco_hue/desktop/ui/generated/

View File

@@ -4,12 +4,14 @@ from PyQt6.QtWidgets import QMainWindow, QMessageBox, QFileDialog
from desktop import BridgeNotRegisteredException, DiscoverBridgesThread
from services import DiscoBall
from .utils import resource_path
class App(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
uic.loadUi('./desktop/ui/main.ui', self)
uic.loadUi(resource_path('desktop/ui/main.ui'), self)
self._settings = QSettings('disco_hue')
self._manager = None
self._selected_light = None

View File

@@ -0,0 +1,13 @@
import os
import sys
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)