LiquidGUI [1.1.0.0] Dev
- Code cleanup & refactoring. - Platform specific code.
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
import platform
|
||||||
|
|
||||||
|
os_type = platform.system()
|
||||||
@@ -1,29 +1,27 @@
|
|||||||
|
# Hard Dependencies.
|
||||||
import sys
|
import sys
|
||||||
from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QProgressBar
|
from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QProgressBar
|
||||||
from PyQt6.QtCore import Qt, QTimer, QThreadPool
|
from PyQt6.QtCore import Qt, QTimer, QThreadPool
|
||||||
from PyQt6.QtGui import QFont, QIcon
|
from PyQt6.QtGui import QFont, QIcon
|
||||||
from LiquidCTL_Helper import LiquidCTL_Helper
|
from LiquidCTL_Helper import LiquidCTL_Helper
|
||||||
|
# Project Imports
|
||||||
from MessageHandler import MessageHandler
|
from MessageHandler import MessageHandler
|
||||||
import resources
|
from styles.Labels import *
|
||||||
from styles.SubLabel import SubLabel
|
import globals
|
||||||
from styles.SubLabelValue import SubLabelValue
|
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QMainWindow):
|
class MainWindow(QMainWindow):
|
||||||
""" Main application window. """
|
""" Main application window. """
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(MainWindow, self).__init__()
|
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.setFixedSize(450, 385)
|
||||||
|
|
||||||
self.lctl = LiquidCTL_Helper()
|
self.lctl = LiquidCTL_Helper()
|
||||||
|
|
||||||
# Widgets ##########################################
|
# Widgets ##########################################
|
||||||
self.lbl_device_name = QLabel(font=QFont("Calibre",
|
self.lbl_device_name = MainLabel(None)
|
||||||
14,
|
|
||||||
weight=QFont.Weight.Bold),
|
|
||||||
alignment=Qt.AlignmentFlag.AlignCenter)
|
|
||||||
|
|
||||||
self.lbl_temp = SubLabel(value="💧 Liquid Temperature:")
|
self.lbl_temp = SubLabel(value="💧 Liquid Temperature:")
|
||||||
self.prg_temp = QProgressBar(textVisible=False,
|
self.prg_temp = QProgressBar(textVisible=False,
|
||||||
minimum=0,
|
minimum=0,
|
||||||
@@ -88,28 +86,33 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" Initialize application and setup window parameters. """
|
""" Initialize application and setup window parameters. """
|
||||||
|
# Setup app and window.
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
icon = QIcon(":/icons/LiquidGUI.ico")
|
icon = QIcon(":/icons/LiquidGUI.ico")
|
||||||
app.setWindowIcon(icon)
|
app.setWindowIcon(icon)
|
||||||
|
|
||||||
window = MainWindow()
|
window = MainWindow()
|
||||||
window.setWindowIcon(icon)
|
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():
|
if window.lctl.TestConnectionState():
|
||||||
MessageHandler().ShowNoDevicesFoundError()
|
MessageHandler().ShowNoDevicesFoundError()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
|
||||||
|
# Handle OS specific tweaks.
|
||||||
|
if globals.os_type == "Windows":
|
||||||
|
window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
import resources
|
||||||
import win32mica
|
import win32mica
|
||||||
win32mica.ApplyMica(window.winId(), win32mica.MICAMODE.DARK)
|
win32mica.ApplyMica(window.winId(), win32mica.MICAMODE.DARK)
|
||||||
window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
print(f"ERROR: Unable to import {e.name}")
|
print(f"ERROR: Unable to import {e.name}")
|
||||||
|
|
||||||
window.show()
|
# Finally run the application.
|
||||||
app.setStyle("Breeze")
|
window.show()
|
||||||
app.exec()
|
app.exec()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
from PyQt6.QtWidgets import QLabel
|
||||||
|
from PyQt6.QtGui import QFont
|
||||||
|
from PyQt6.QtCore import Qt
|
||||||
|
import styles
|
||||||
|
|
||||||
|
class MainLabel(QLabel):
|
||||||
|
""" Formatting for the main label. """
|
||||||
|
def __init__(self, value):
|
||||||
|
super().__init__()
|
||||||
|
self.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||||
|
self.setFont(QFont(styles.sublabel_font, 16, weight=QFont.Weight.Bold))
|
||||||
|
self.setText(value)
|
||||||
|
|
||||||
|
class SubLabel(QLabel):
|
||||||
|
""" Formatting for sub-labels. """
|
||||||
|
def __init__(self, value):
|
||||||
|
super().__init__()
|
||||||
|
self.setFont(QFont(styles.mainlabel_font, 10, weight=QFont.Weight.Bold))
|
||||||
|
self.setText(value)
|
||||||
|
|
||||||
|
class SubLabelValue(QLabel):
|
||||||
|
""" Formatting for values. """
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.setAlignment(Qt.AlignmentFlag.AlignRight)
|
||||||
|
self.setFont(QFont(styles.sublabelvalue_font, 8))
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
from PyQt6.QtWidgets import QLabel
|
|
||||||
from PyQt6.QtGui import QFont
|
|
||||||
|
|
||||||
class SubLabel(QLabel):
|
|
||||||
""" Formatting for sub-labels. """
|
|
||||||
def __init__(self, value):
|
|
||||||
super().__init__()
|
|
||||||
self.setFont(QFont("Calibre", 10, weight=QFont.Weight.Bold))
|
|
||||||
self.setText(value)
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
from PyQt6.QtWidgets import QLabel
|
|
||||||
from PyQt6.QtGui import QFont
|
|
||||||
from PyQt6.QtCore import Qt
|
|
||||||
|
|
||||||
class SubLabelValue(QLabel):
|
|
||||||
""" Formatting for values. """
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__()
|
|
||||||
self.setAlignment(Qt.AlignmentFlag.AlignRight)
|
|
||||||
self.setFont(QFont("Cascadia Code", 8))
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
from PyQt6.QtGui import QFont
|
||||||
|
import globals
|
||||||
|
|
||||||
|
mainlabel_font = None
|
||||||
|
sublabel_font = None
|
||||||
|
sublabelvalue_font = None
|
||||||
|
|
||||||
|
if globals.os_type == "Windows":
|
||||||
|
sublabelvalue_font = "Cascadia Code"
|
||||||
|
sublabel_font = "Calibre"
|
||||||
|
mainlabel_font = "Calibre"
|
||||||
|
elif globals.os_type == "Linux":
|
||||||
|
sublabelvalue_font = "Liberation Mono"
|
||||||
|
sublabel_font = "Cantarell"
|
||||||
|
mainlabel_font = "Cantarell"
|
||||||
Reference in New Issue
Block a user