LiquidGUI [1.1.0.0] DEV

- Code refactoring.
- Created main method on main file.
- Made MessageHander static
This commit is contained in:
2023-08-20 12:38:17 +01:00
parent a3ee61bff1
commit 160a52db66
2 changed files with 39 additions and 32 deletions
+38 -32
View File
@@ -9,17 +9,17 @@ from LiquidCTL_Helper import LiquidCTL_Helper
from MessageHandler import MessageHandler
class MainWindow(QMainWindow):
def __init__(self):
def __init__(self, lctl):
super(MainWindow, self).__init__()
self.setWindowTitle("LiquidGUI (v.1.1.0.0)")
self.setFixedSize(450, 350)
self.setWindowFlags(Qt.WindowType.Dialog)
widget = QWidget(self)
font_style = QFont("Calibri", 16, weight=QFont.Weight.Bold)
self.lctl = lctl
self.lbl_device_name = QLabel()
self.lbl_device_name.setFont(font_style)
# Widgets ##########################################
self.lbl_device_name = QLabel(font=QFont("Calibri", 16, weight=QFont.Weight.Bold),
alignment=Qt.AlignmentFlag.AlignCenter)
self.lbl_temp = QLabel("Liquid Temperature:")
self.prg_temp = QProgressBar(format="%v°C",
minimum=0,
@@ -34,8 +34,11 @@ class MainWindow(QMainWindow):
maximum=2700)
self.btn_maxFanSpeed = QPushButton(text="Max Fan Speed")
self.btn_maxFanSpeed.clicked.connect(self.max_fan_speed)
self.lbl_fwVers = QLabel()
self.lbl_fwVers = QLabel(alignment=Qt.AlignmentFlag.AlignRight)
# Layout ##########################################
widget = QWidget(self)
layout = QVBoxLayout(widget)
layout.addWidget(self.lbl_device_name)
layout.addWidget(self.lbl_temp)
@@ -52,43 +55,46 @@ class MainWindow(QMainWindow):
self.setCentralWidget(widget)
self.setContentsMargins(40, 20, 40, 20)
# Threading #######################################
self.thread_manager = QThreadPool()
self.timer = QTimer()
self.timer.setInterval(1000)
self.timer.timeout.connect(lambda: self.thread_manager.start(lctl_helper.Update))
self.timer.timeout.connect(lambda: self.thread_manager.start(self.lctl.Update))
self.timer.timeout.connect(self.update_widgets)
self.timer.start()
self.timer.start()
def update_widgets(self):
self.lbl_device_name.setText(lctl_helper.device_name)
self.prg_temp.setValue(lctl_helper.device_temp)
self.prg_fanSpeed.setValue(lctl_helper.device_fanSpeed)
self.prg_pumpSpeed.setValue(lctl_helper.device_pumpSpeed)
if lctl_helper.device_fwVers != None:
self.lbl_fwVers.setText(f"Firmware: v{lctl_helper.device_fwVers}")
self.lbl_device_name.setText(self.lctl.device_name)
self.prg_temp.setValue(self.lctl.device_temp)
self.prg_fanSpeed.setValue(self.lctl.device_fanSpeed)
self.prg_pumpSpeed.setValue(self.lctl.device_pumpSpeed)
if self.lctl.device_fwVers != None:
self.lbl_fwVers.setText(f"Firmware: v{self.lctl.device_fwVers}")
def max_fan_speed(self):
lctl_helper.SetFanSpeed(100)
app = QApplication(sys.argv)
icon = QIcon(":/icons/LiquidGUI.ico")
app.setWindowIcon(icon)
self.lctl.SetFanSpeed(100)
messagehandler = MessageHandler()
lctl_helper = LiquidCTL_Helper()
# Show error and quit app if no devices are found
if lctl_helper.TestConnectionState() == True:
messagehandler.ShowNoDevicesFoundError()
sys.exit(1)
def main():
app = QApplication(sys.argv)
icon = QIcon(":/icons/LiquidGUI.ico")
app.setWindowIcon(icon)
window = MainWindow()
window.setWindowIcon(icon)
window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
window = MainWindow(LiquidCTL_Helper())
window.setWindowIcon(icon)
window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
qdarktheme.setup_theme("dark", custom_colors={"background": "#00000000"})
win32mica.ApplyMica(window.winId(), win32mica.MICAMODE.DARK)
qdarktheme.setup_theme("dark", custom_colors={"background": "#00000000"})
win32mica.ApplyMica(window.winId(), win32mica.MICAMODE.DARK)
window.show()
app.exec()
# Show error and quit app if no devices are found
if window.lctl.TestConnectionState() == True:
MessageHandler.ShowNoDevicesFoundError()
sys.exit(1)
else:
window.show()
app.exec()
if __name__ == "__main__":
main()
+1
View File
@@ -1,5 +1,6 @@
from PySide6.QtWidgets import QMessageBox
@staticmethod
class MessageHandler():
def ShowNoDevicesFoundError(self):
msg = QMessageBox()