diff --git a/mucapy/main.py b/mucapy/main.py index 1555cd3..a8208e4 100644 --- a/mucapy/main.py +++ b/mucapy/main.py @@ -21,6 +21,11 @@ import time import requests import subprocess +class getpath: + def resource_path(relative_path): + base_path = getattr(sys, '_MEIPASS', os.path.abspath(".")) + return os.path.join(base_path, relative_path) + class Config: def __init__(self): # Use platform-specific user directory for config @@ -852,7 +857,8 @@ class AboutWindow(QDialog): layout.addWidget(close_btn, alignment=Qt.AlignCenter) # Set Styling for About Section - with open("styling/about.qss","r") as aboutstyle: + style_file = getpath.resource_path("mucapy/styling/about.qss") + with open(style_file,"r") as aboutstyle: self.setStyleSheet(aboutstyle.read()) self.setLayout(layout) @@ -1425,7 +1431,8 @@ class MainWindow(QMainWindow): self.hw_timer.start(1000) # Update every second # Set dark theme style - with open("styling/mainwindow.qss", "r") as mainstyle: + style_file = getpath.resource_path("styling/mainwindow.qss") + with open(style_file, "r") as mainstyle: self.setStyleSheet(mainstyle.read()) # Set palette for better dark mode support @@ -1941,7 +1948,8 @@ class MainWindow(QMainWindow): self.cpu_progress.setFormat("%p%") # Set Styling from cpu progress QSS file - with open("styling/cpu_progress.qss","r") as cpu_progress_style: + style_file = getpath.resource_path("styling/cpu_progress.qss") + with open(style_file,"r") as cpu_progress_style: self.cpu_progress.setStyleSheet(cpu_progress_style.read()) cpu_layout.addWidget(self.cpu_progress) @@ -1958,7 +1966,8 @@ class MainWindow(QMainWindow): core_bar.setTextVisible(True) core_bar.setFormat("%p%") - with open("styling/core_bar.qss","r") as core_bar_styling: + core_file = getpath.resource_path("styling/core_bar.qss") + with open(core_file,"r") as core_bar_styling: core_bar.setStyleSheet(core_bar_styling.read()) cores_layout.addWidget(core_label, i, 0) @@ -2190,15 +2199,18 @@ class MainWindow(QMainWindow): for bar in [self.cpu_progress] + self.core_bars: value = bar.value() if value < 60: - with open("styling/bar/u60.qss","r") as u60_style: + u60 = getpath.resource_path("styling/bar/u60.qss") + with open(u60,"r") as u60_style: bar.setStyleSheet(u60_style.read()) elif value < 85: - with open("styling/bar/a85.qss","r") as a85_styling: + u85 = getpath.resource_path("styling/bar/a85.qss") + with open(u85,"r") as a85_styling: bar.setStyleSheet(a85_styling.read()) else: - with open("styling/bar/else.qss", "r") as else_style: + else_file = getpath.resource_path("styling/bar/else.qss") + with open(else_file, "r") as else_style: bar.setStyleSheet(else_style.read())