# zcy_pyside_template **Repository Path**: modelview/zcy_pyside_template ## Basic Information - **Project Name**: zcy_pyside_template - **Description**: 使用pyside构建的无边框应用程序,并增加了自定义的标题栏。 使用 qt-material作为主题色,并修复了一些样式表示 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-07-21 - **Last Updated**: 2025-09-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 项目介绍 - 建立 PySide6 的桌面程序 - 通过主题美化基本控件 - 采用自定义的无边框界面 ## 技术栈 - python 作为业务逻辑编程语言 - pyside6 作为 ui - openpyxl 解析 xlsx 文件,生成 xlsx 文件 - sqlite 作为本地数据库 - 界面主题 qt-material - pyinstaller 打包 ## 主题 - theme 目录包含主要图片。从 qt-material 导出 - dark_teal.qss 主题的控件样式,自定义了 - logo.ico 用于打包 - logo.png 用于显示在界面 ## 运行打包 - 直接通过 F5 运行 main.py 执行程序 - 采用 pyinstall 进行打包 - 通过批处理命令完成版本和自动化打包 - 获取版本号命令如下 ```bat @echo off for /f "delims=" %%a in ('git describe --tags --abbrev^=0 2^>nul') do set "TAG_VERSION=%%a" echo 当前Git版本号: %TAG_VERSION% ``` - 版本更新后命令如下 ```bat REM 更新标签版本 git tag -a v0.0.1 -m "注释" REM 推送全部的标签 git push origin --tags ``` ## 工具包 - util 目录中 - LogUtil 记录日志 - MessageUtil 显示中文对话框 - ThemeUtil 主题工具包 - UiUtil 用于加载界面 ## 界面 ui - view 目录为主要的界面逻辑 - MainWindow.py 主窗口 - TitleBar.py 标题栏 - ProgressDlg.py 进度对话框 - ChildWindow1.py ChildWindow1.py 是子窗口 - 通过 UiUtil 中的 TabName 指定名称 - ui 目录为对应界面的设计文件 \*.ui - icon 目录为界面自定义 svg 图标。颜色固定 ## 标题栏背景色 - 由于设置 layout 之后,背景色仅仅限定在各个分块之中,gap 会透明显示 - 所以需要在增加一个底色,才能确保全部覆盖 ```python layout = QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) centerWidget = QWidget(self) layout.addWidget(centerWidget) layout2 = QHBoxLayout(centerWidget) layout2.setContentsMargins(0, 0, 0, 0) label = QLabel("hehe") label.setMinimumHeight(30) layout2.addWidget(label) btn = QPushButton("lala") layout2.addWidget(btn) self.setStyleSheet(""" background-color: lime; border-radius: 0px; """) ``` ## 调试 - 为了支持 F5 直接调试程序,可以增加 .vscode/launch.json 文件 ```json { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Python Debugger: Main File", "type": "debugpy", "request": "launch", "program": "${workspaceFolder}/main.py", "console": "integratedTerminal" } ] } ```