From 3c60b3e7cae56c0f729a727a4995b3d8c58b41e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AF=92=E5=AF=92?= <2596194220@qq.com>
Date: Sun, 21 Dec 2025 23:17:35 +0800
Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BC=98=E5=8C=96=E4=B8=80?=
=?UTF-8?q?=E4=BA=9B=E5=91=BD=E5=90=8D=E8=A7=84=E8=8C=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 4 ++-
.idea/workspace.xml | 86 +++++++++++++++++++++++++++++++--------------
IFLOW.md | 18 ++++++----
README.md | 6 ++--
config.toml | 2 +-
main_nicegui.py | 31 +++++++++-------
6 files changed, 96 insertions(+), 51 deletions(-)
diff --git a/.gitignore b/.gitignore
index 6198c26..d5f317d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,4 +11,6 @@ wheels/
output/*.pptx
output/*.pdf
data/images/*
-data/*.xlsx
\ No newline at end of file
+data/*.xlsx
+
+.idea/
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 0c14bd0..ac3bac1 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,13 @@
-
+
+
+
+
+
-
@@ -17,33 +20,34 @@
-
+ {
+ "customColor": "",
+ "associatedIndex": 0
+}
- {
+ "keyToString": {
+ "ModuleVcsDetector.initialDetectionPerformed": "true",
+ "Python.main_nicegui.executor": "Run",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "RunOnceActivity.typescript.service.memoryLimit.init": "true",
+ "SHARE_PROJECT_CONFIGURATION_FILES": "true",
+ "git-widget-placeholder": "master",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "settings.editor.selected.configurable": "preferences.lookFeel",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
+}
@@ -59,6 +63,7 @@
+
@@ -74,6 +79,14 @@
+
+
+
+
+
+
+
+
@@ -81,7 +94,14 @@
1766149044347
-
+
+
+
+
+
+
+
+
@@ -99,7 +119,15 @@
1766151466883
-
+
+
+ 1766152994686
+
+
+
+ 1766152994686
+
+
@@ -118,9 +146,13 @@
-
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/IFLOW.md b/IFLOW.md
index a339cf8..bf3260a 100644
--- a/IFLOW.md
+++ b/IFLOW.md
@@ -2,7 +2,7 @@
## 项目概述
-这是一个基于Python的自动化幼儿园成长报告生成系统。该系统可以从Excel数据文件中读取幼儿信息,结合AI生成个性化评语,并将所有信息批量填充到PPT模板中,最终生成每个学生的个性化成长报告。系统支持双界面运行(命令行界面、图形界面和NiceGUI界面),具备字体安装、图片替换、批量PDF转换、生肖计算等功能。
+基于Python的自动化幼儿园学期成长报告生成系统。该系统可以从Excel数据文件中读取幼儿信息,结合AI生成个性化评语,并将所有信息批量填充到PPT模板中,最终生成每个学生的个性化成长报告。系统支持UI界面操作,具备字体安装、图片替换、批量PDF转换、生肖计算、模板导出等完整功能。
## 技术栈
@@ -47,17 +47,23 @@
- 批量更新Excel中的生肖信息
- 支持日期格式自动识别
-### 6. 导出数据模板 (📦 导出数据模板)
+### 6. 园长一键签名 (💴 园长一键签名)
+
+- 一键为所有生成的报告添加园长签名
+- 自动识别输出文件夹中的PPT文件
+- 批量替换签名占位符为实际签名图片
+
+### 7. 导出数据模板 (📦 导出数据模板)
- 生成标准化的数据模板ZIP包
- 包含示例Excel文件和图片文件夹结构
- 方便新用户快速上手
-### 7. 初始化系统 (📤 初始化系统)
+### 8. 初始化系统 (📤 初始化系统)
- 自动创建必要的目录结构
- 安装所需字体文件
- 配置系统环境
-### 8. 字体安装 (🔤 字体安装)
+### 9. 字体安装 (🔤 字体安装)
- 自动检测系统是否安装了指定字体
- 自动安装项目所需的字体文件
- 支持方正兰亭黑简体和方正少儿简体字体
@@ -70,7 +76,7 @@ growth_report/
├── UI.py # 图形用户界面入口(tkinter)
├── main_nicegui.py # NiceGUI界面入口
├── main.pyw # Windows图形界面启动文件
-├── config.env.toml # 项目配置文件
+├── config.toml # 项目配置文件
├── pyproject.toml # 项目依赖配置
├── start_app.bat # Windows启动批处理文件
├── README.md # 项目说明文档
@@ -199,7 +205,7 @@ pip install -r requirements.txt
### 初始化设置
-1. 编辑`config.env.toml`配置文件,设置API密钥和其他参数
+1. 编辑`config.toml`配置文件,设置API密钥和其他参数
2. 准备Excel数据文件(按指定格式)
3. 准备图片资源文件夹(按指定结构)
4. 准备PPT模板文件
diff --git a/README.md b/README.md
index 56d36fa..bc7a5f5 100644
--- a/README.md
+++ b/README.md
@@ -60,7 +60,7 @@ pip install -r requirements.txt
### 3. 配置系统
-编辑 `config.env.toml` 文件,设置以下信息:
+编辑 `config.toml` 文件,设置以下信息:
- AI API密钥和配置
- 班级信息和教师名单
@@ -140,7 +140,7 @@ growth_report/
├── UI.py # 图形用户界面入口(tkinter)
├── main_nicegui.py # NiceGUI界面入口
├── main.pyw # Windows图形界面启动文件
-├── config.env.toml # 项目配置文件
+├── config.toml # 项目配置文件
├── pyproject.toml # 项目依赖配置
├── start_app.bat # 启动脚本
├── README.md # 项目说明文档
@@ -204,7 +204,7 @@ growth_report/
### AI配置
-在 `config.env.toml` 中配置AI模型:
+在 `config.toml` 中配置AI模型:
```toml
[ai]
diff --git a/config.toml b/config.toml
index 4be8979..1460574 100644
--- a/config.toml
+++ b/config.toml
@@ -4,7 +4,7 @@ output_folder = "output"
excel_file = "names.xlsx"
image_folder = "images"
fonts_dir = "fonts"
-signature_image = "C:\\Users\\Administrator\\Desktop\\文档资料\\code\\growth_report\\data\\"
+signature_image = "D:\\working\\tools\\growth_report\\data\\"
[class_info]
class_name = "K3A"
diff --git a/main_nicegui.py b/main_nicegui.py
index c05b2d6..519cac0 100644
--- a/main_nicegui.py
+++ b/main_nicegui.py
@@ -1,17 +1,17 @@
import os
import sys
-
-from nicegui import ui, app, run, native
-from loguru import logger
-
-from screeninfo import get_monitors
import traceback
+
+from loguru import logger
+from nicegui import ui, app, run, native
+from screeninfo import get_monitors
+
from config.config import load_config
# 导入我们的模块
from ui.core.logger import setup_logger
-from utils.font_utils import install_fonts_from_directory
-from ui.views.home_page import create_home_page
from ui.views.config_page import create_config_page
+from ui.views.home_page import create_home_page
+from utils.font_utils import install_fonts_from_directory
sys.stdout.reconfigure(encoding='utf-8')
sys.stderr.reconfigure(encoding='utf-8')
@@ -20,6 +20,7 @@ config = load_config("config.toml")
setup_logger()
+
# === 关键修改:定义一个获取路径的通用函数 ===
def get_path(relative_path):
"""
@@ -47,42 +48,46 @@ def calculate_window_size():
m = monitors[0]
screen_width = m.width
screen_height = m.height
-
+
# 设置窗口宽度为屏幕宽度的 30%
target_width = int(screen_width * 0.30)
# 设置窗口高度为屏幕高度的 60%
target_height = int(screen_height * 0.60)
-
+
# 确保窗口有一个合理的最小值 (例如 800x600)
min_width = 800
min_height = 700
-
+
target_width = max(target_width, min_width)
target_height = max(target_height, min_height)
-
+
logger.info(f"屏幕分辨率: {screen_width}x{screen_height}")
logger.info(f"设置窗口大小为: {target_width}x{target_height}")
-
+
return target_width, target_height
-
+
except Exception as e:
logger.warning(f"无法获取屏幕分辨率 ({e}),使用默认大小 (900, 900)")
return 900, 900 # 失败时的默认值
+
# 1. 挂载静态资源 (CSS/图片)
# 注意:这里使用 get_path 确保打包后能找到
static_dir = get_path(os.path.join("ui", "assets"))
app.add_static_files('/assets', static_dir)
+
# 3. 页面路由
@ui.page('/')
def index_page():
create_home_page()
+
@ui.page('/config')
def config_page():
create_config_page()
+
# 4. 启动时钩子
async def startup_check():
try: