""" SSHClient 入口 """ import sys import os from pathlib import Path # 让 PyInstaller 打包后能找到资源 def _setup_path(): if getattr(sys, "frozen", False): # 打包后:exe 所在目录 bundle_dir = Path(sys.executable).parent sys.path.insert(0, str(bundle_dir)) else: # 源码运行:项目根 sys.path.insert(0, str(Path(__file__).parent)) _setup_path() from PyQt5.QtWidgets import QApplication from PyQt5.QtCore import Qt from PyQt5.QtGui import QFont from ui.main_window import MainWindow, APP_NAME def main(): # Windows 上高 DPI 适配 if hasattr(Qt, "AA_EnableHighDpiScaling"): QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True) if hasattr(Qt, "AA_UseHighDpiPixmaps"): QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True) app = QApplication(sys.argv) app.setApplicationName(APP_NAME) app.setStyle("Fusion") # 全局等宽字体偏好 f = QFont("Consolas", 10) app.setFont(f) w = MainWindow() w.show() sys.exit(app.exec_()) if __name__ == "__main__": main()