LiquidGUI [1.0.1.2]

- Error handling and app termination for no compatible coolers.
- Minor code refactoring.
This commit is contained in:
2023-08-18 21:37:59 +01:00
parent 9e38120cfb
commit 7b32a214df
3 changed files with 35 additions and 15 deletions
+15 -10
View File
@@ -13,20 +13,25 @@ class LiquidCTL_Init():
#print(f'{dev.description}')
device_name = dev.description
init_status = dev.initialize()
if init_status:
for key, value, unit in init_status:
#print(f'- {key}: {value} {unit}')
device_fwVers = value
def TestConnectionState(self):
if self.device_name != None:
return False
else:
return True
def Update(self):
with self.dev.connect():
status = self.dev.get_status()
for key, value, unit in status:
#print(f'- {key}: {value} {unit}')
if key == "Liquid temperature":
self.device_temp = value
elif key == "Fan speed":
self.device_fanSpeed = value
elif key == "Pump speed":
self.device_pumpSpeed = value
status = self.dev.get_status()
for key, value, unit in status:
#print(f'- {key}: {value} {unit}')
if key == "Liquid temperature":
self.device_temp = value
elif key == "Fan speed":
self.device_fanSpeed = value
elif key == "Pump speed":
self.device_pumpSpeed = value
+10 -5
View File
@@ -1,16 +1,17 @@
import sys
import qdarktheme
import win32mica
import liquidctl_worker
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_worker import LiquidCTL_Init
from messagehandler import MessageHandler
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.setWindowTitle("LiquidGUI (v.1.0.0.1)")
self.setWindowTitle("LiquidGUI (v.1.0.1.2)")
self.setFixedSize(450, 300)
self.setWindowFlags(Qt.WindowType.Dialog)
widget = QWidget(self)
@@ -56,7 +57,6 @@ class MainWindow(QMainWindow):
self.timer.timeout.connect(self.update_widgets)
self.timer.start()
def update_widgets(self):
self.lbl_device_name.setText(lctl_worker.device_name)
self.prg_temp.setValue(lctl_worker.device_temp)
@@ -66,11 +66,16 @@ class MainWindow(QMainWindow):
self.lbl_fwVers.setText(f"Firmware: v{lctl_worker.device_fwVers}")
app = QApplication(sys.argv)
icon = QIcon(":/icons/LiquidGUI.ico")
app.setWindowIcon(icon)
lctl_worker = liquidctl_worker.LiquidCTL_Init()
messagehandler = MessageHandler()
lctl_worker = LiquidCTL_Init()
# Show error and quit app if no devices are found
if lctl_worker.TestConnectionState() == True:
messagehandler.ShowNoDevicesFoundError()
sys.exit(1)
window = MainWindow()
window.setWindowIcon(icon)
+10
View File
@@ -0,0 +1,10 @@
from PySide6.QtWidgets import QMessageBox
class MessageHandler():
def ShowNoDevicesFoundError(self):
msg = QMessageBox()
msg.setWindowTitle("LiquidGUI Error")
msg.setText("No suitable devices could be detected. Please ensure you have a cooler \
both compatible with LiquidCTL, and connected to the system.")
msg.setIcon(QMessageBox.Icon.Warning)
msg.exec()