iBook/UI_README.md

50 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# UI 开发说明
## 文件结构
- `ibook_export_app.ui` - Qt Designer 界面文件
- `generate_ui.py` - 界面代码生成脚本
- `ibook_export_app.py` - 主应用程序
## 使用 Qt Designer 编辑界面
1. 安装 PyQt6-tools
```bash
pip install PyQt6-tools
```
2. 打开 Qt Designer
```bash
designer ibook_export_app.ui
```
3. 在 Designer 中编辑界面
4. 保存 .ui 文件
## 生成界面代码
有两种方式使用界面:
### 方式1直接加载 .ui 文件(推荐)
当前代码使用 `uic.loadUi()` 直接加载 .ui 文件,无需生成额外代码。
### 方式2生成 Python 界面代码
如果需要生成 Python 代码:
```bash
python generate_ui.py
```
这会生成 `ui_ibook_export_app.py` 文件。
## 注意事项
1. .ui 文件中的控件名称必须与代码中引用的名称一致:
- `listwidget` - 书籍列表
- `export_btn` - 导出按钮
- `config_btn` - 配置按钮
2. 修改界面后直接运行应用即可看到效果,无需重新生成代码
3. 如果在 Designer 中添加新控件,记得在代码中添加相应的信号连接