hopefully it works now, made a function that gets the cwd and then joins it!
All checks were successful
Build MuCaPy Executable / build-and-package (push) Successful in 1m42s

This commit is contained in:
rattatwinko
2025-06-02 14:21:55 +02:00
parent b3b3d77394
commit 98ad6242fa

View File

@@ -21,6 +21,11 @@ import time
import requests import requests
import subprocess 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: class Config:
def __init__(self): def __init__(self):
# Use platform-specific user directory for config # Use platform-specific user directory for config
@@ -852,7 +857,8 @@ class AboutWindow(QDialog):
layout.addWidget(close_btn, alignment=Qt.AlignCenter) layout.addWidget(close_btn, alignment=Qt.AlignCenter)
# Set Styling for About Section # 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.setStyleSheet(aboutstyle.read())
self.setLayout(layout) self.setLayout(layout)
@@ -1425,7 +1431,8 @@ class MainWindow(QMainWindow):
self.hw_timer.start(1000) # Update every second self.hw_timer.start(1000) # Update every second
# Set dark theme style # 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()) self.setStyleSheet(mainstyle.read())
# Set palette for better dark mode support # Set palette for better dark mode support
@@ -1941,7 +1948,8 @@ class MainWindow(QMainWindow):
self.cpu_progress.setFormat("%p%") self.cpu_progress.setFormat("%p%")
# Set Styling from cpu progress QSS file # 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()) self.cpu_progress.setStyleSheet(cpu_progress_style.read())
cpu_layout.addWidget(self.cpu_progress) cpu_layout.addWidget(self.cpu_progress)
@@ -1958,7 +1966,8 @@ class MainWindow(QMainWindow):
core_bar.setTextVisible(True) core_bar.setTextVisible(True)
core_bar.setFormat("%p%") 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()) core_bar.setStyleSheet(core_bar_styling.read())
cores_layout.addWidget(core_label, i, 0) cores_layout.addWidget(core_label, i, 0)
@@ -2190,15 +2199,18 @@ class MainWindow(QMainWindow):
for bar in [self.cpu_progress] + self.core_bars: for bar in [self.cpu_progress] + self.core_bars:
value = bar.value() value = bar.value()
if value < 60: 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()) bar.setStyleSheet(u60_style.read())
elif value < 85: 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()) bar.setStyleSheet(a85_styling.read())
else: 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()) bar.setStyleSheet(else_style.read())