Files
LiquidGUI/main.pyw
Dunestorm 5487a689a6 LiquidGUI [1.0.1.3] Bugfix Release
- Moved device init into dedicated function to prevent unwanted
device re-init.
- Library renaming.
2023-08-19 19:50:26 +01:00

88 lines
3.2 KiB
Python

import sys
import qdarktheme
import win32mica
import resources
from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QProgressBar, QGroupBox
from PySide6.QtCore import Qt, QTimer, QThreadPool
from PySide6.QtGui import QFont, QIcon
from LiquidCTL_Helper import LiquidCTL_Helper
from MessageHandler import MessageHandler
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.setWindowTitle("LiquidGUI (v.1.0.1.2)")
self.setFixedSize(450, 300)
self.setWindowFlags(Qt.WindowType.Dialog)
widget = QWidget(self)
font_style = QFont("Calibri", 16, weight=QFont.Weight.Bold)
self.lbl_device_name = QLabel()
self.lbl_device_name.setFont(font_style)
self.lbl_temp = QLabel("Liquid Temperature:")
self.prg_temp = QProgressBar(format="%v°C",
minimum=0,
maximum=50)
self.lbl_fanSpeed = QLabel("Fan Speed:")
self.prg_fanSpeed = QProgressBar(format="%v rpm",
minimum=520,
maximum=1700)
self.lbl_pumpSpeed = QLabel("Pump Speed:")
self.prg_pumpSpeed = QProgressBar(format="%v rpm",
minimum=1900,
maximum=2700)
self.lbl_fwVers = QLabel()
layout = QVBoxLayout(widget)
layout.addWidget(self.lbl_device_name)
layout.addWidget(self.lbl_temp)
layout.addWidget(self.prg_temp)
layout.addWidget(self.lbl_fanSpeed)
layout.addWidget(self.prg_fanSpeed)
layout.addWidget(self.lbl_pumpSpeed)
layout.addWidget(self.prg_pumpSpeed)
layout.addWidget(self.lbl_fwVers)
layout.setSpacing(10)
self.setLayout(layout)
self.setCentralWidget(widget)
self.setContentsMargins(40, 20, 40, 20)
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(self.update_widgets)
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}")
app = QApplication(sys.argv)
icon = QIcon(":/icons/LiquidGUI.ico")
app.setWindowIcon(icon)
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)
window = MainWindow()
window.setWindowIcon(icon)
window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
qdarktheme.setup_theme("dark", custom_colors={"background": "#00000000"})
win32mica.ApplyMica(window.winId(), win32mica.MICAMODE.DARK)
window.show()
app.exec()