LiquidGUI [1.1.0.0] Dev

- Code cleanup & refactoring.
- Platform specific code.
This commit is contained in:
2024-07-09 22:00:56 +01:00
parent aed37b7fae
commit 65456aa5c6
6 changed files with 64 additions and 36 deletions
+20 -17
View File
@@ -1,29 +1,27 @@
# Hard Dependencies.
import sys
from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QProgressBar
from PyQt6.QtCore import Qt, QTimer, QThreadPool
from PyQt6.QtGui import QFont, QIcon
from LiquidCTL_Helper import LiquidCTL_Helper
# Project Imports
from MessageHandler import MessageHandler
import resources
from styles.SubLabel import SubLabel
from styles.SubLabelValue import SubLabelValue
from styles.Labels import *
import globals
class MainWindow(QMainWindow):
""" Main application window. """
def __init__(self):
super(MainWindow, self).__init__()
self.setWindowTitle("LiquidGUI (v.1.1.0.0)")
self.setWindowTitle("LiquidGUI (v.1.1.0.0) DEV")
self.setFixedSize(450, 385)
self.lctl = LiquidCTL_Helper()
# Widgets ##########################################
self.lbl_device_name = QLabel(font=QFont("Calibre",
14,
weight=QFont.Weight.Bold),
alignment=Qt.AlignmentFlag.AlignCenter)
# Widgets ##########################################
self.lbl_device_name = MainLabel(None)
self.lbl_temp = SubLabel(value="💧 Liquid Temperature:")
self.prg_temp = QProgressBar(textVisible=False,
minimum=0,
@@ -88,28 +86,33 @@ class MainWindow(QMainWindow):
def main():
""" Initialize application and setup window parameters. """
# Setup app and window.
app = QApplication(sys.argv)
icon = QIcon(":/icons/LiquidGUI.ico")
app.setWindowIcon(icon)
window = MainWindow()
window.setWindowIcon(icon)
# Show error and quit app if no devices are found
# Show error and quit app if no devices are found.
if window.lctl.TestConnectionState():
MessageHandler().ShowNoDevicesFoundError()
sys.exit(1)
else:
# Handle OS specific tweaks.
if globals.os_type == "Windows":
window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
try:
import resources
import win32mica
win32mica.ApplyMica(window.winId(), win32mica.MICAMODE.DARK)
window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
except ImportError as e:
print(f"ERROR: Unable to import {e.name}")
window.show()
app.setStyle("Breeze")
app.exec()
# Finally run the application.
window.show()
app.exec()
if __name__ == "__main__":