#!/usr/bin/env python # -*- coding: utf-8 -*- """ HART通信工具主程序 基于PyQt的现代化HART通信界面应用程序 """ import sys import os from PyQt5.QtWidgets import QApplication from PyQt5.QtCore import QFile, QTextStream from UI.HartWidgets.HartMainWindow import HartMainWindow def loadStyleSheet(sheetName): """ 加载样式表 Args: sheetName: 样式表文件名 Returns: 样式表内容 """ file = QFile(sheetName) file.open(QFile.ReadOnly | QFile.Text) stream = QTextStream(file) return stream.readAll() def main(): """ 主函数 """ # 创建应用程序 app = QApplication(sys.argv) # 设置应用程序样式 styleSheetPath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "style.qss") if os.path.exists(styleSheetPath): app.setStyleSheet(loadStyleSheet(styleSheetPath)) # 创建主窗口 mainWindow = HartMainWindow() mainWindow.setWindowTitle("HART通信工具") mainWindow.resize(800, 600) mainWindow.show() # 运行应用程序 sys.exit(app.exec_()) if __name__ == "__main__": main()