Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dff39db5b6 | |||
| 5e229d7797 | |||
| ff1314ab88 | |||
| 283ef3e497 | |||
| 4b9e809beb | |||
| c08482f343 | |||
| bab2196ab7 | |||
| 84b1ca880f | |||
| 74376e8627 | |||
| 29e2865d93 | |||
| 768da4d37f | |||
| 9216a36e0c | |||
| 50e9a1a9d9 | |||
| c26db5c179 | |||
| eb5d41914c | |||
| 668d77363a | |||
| 2cad7ebbac | |||
| bb76e0bba4 | |||
| 662b1535e9 | |||
| 85c6c5c127 | |||
| 2f3a357ff7 | |||
| 672bc30edb | |||
| 9126c58e9c | |||
| 42a9c964c9 | |||
| 6cf05da422 | |||
| 3680b22407 | |||
| 908b134e50 | |||
| ca2fc4ac46 | |||
| f1b6d4cd09 | |||
|
0d66a5c424
|
|||
|
37bbfba299
|
|||
|
34c5323df3
|
|||
|
30d63fa193
|
|||
|
be3fdb0988
|
|||
|
ba9472d0b1
|
|||
| 1791b4b05c | |||
|
f8d1ba3d4e
|
@@ -1,321 +0,0 @@
|
|||||||
# FastAPI WebUI Migration Guide
|
|
||||||
|
|
||||||
## 概述 / Overview
|
|
||||||
|
|
||||||
本项目的 WebUI 已重构为使用 FastAPI 作为后端,提供现代化的 REST API 架构,同时保持与原有 PyWebIO 界面一致的视觉风格。
|
|
||||||
|
|
||||||
The WebUI has been refactored to use FastAPI as the backend, providing a modern REST API architecture while maintaining a visual style consistent with the original PyWebIO interface.
|
|
||||||
|
|
||||||
## 主要变化 / Key Changes
|
|
||||||
|
|
||||||
### 新增功能 / New Features
|
|
||||||
|
|
||||||
1. **FastAPI 后端** / **FastAPI Backend**
|
|
||||||
- 完整的 REST API 支持
|
|
||||||
- 自动生成的 API 文档 (访问 `/docs`)
|
|
||||||
- WebSocket 支持实时日志流
|
|
||||||
- 更好的错误处理和验证
|
|
||||||
|
|
||||||
2. **分离的前后端架构** / **Separated Frontend/Backend Architecture**
|
|
||||||
- 后端: FastAPI (REST API)
|
|
||||||
- 前端: HTML/CSS/JavaScript
|
|
||||||
- 可以被多种客户端使用 (Web, Mobile, CLI)
|
|
||||||
|
|
||||||
3. **向后兼容** / **Backward Compatible**
|
|
||||||
- 原有的 PyWebIO 界面仍然可用
|
|
||||||
- 两个后端可以同时存在
|
|
||||||
|
|
||||||
### 架构对比 / Architecture Comparison
|
|
||||||
|
|
||||||
| 特性 / Feature | PyWebIO (原有) | FastAPI (新) |
|
|
||||||
|----------------|---------------|-------------|
|
|
||||||
| 启动命令 / Launch | `python gui.py` | `python gui_fastapi.py` |
|
|
||||||
| 架构 / Architecture | 单体应用 | 前后端分离 |
|
|
||||||
| API 访问 / API Access | 有限 | 完整 REST API |
|
|
||||||
| 实时更新 / Real-time | Session-based | WebSocket |
|
|
||||||
| 文档 / Documentation | 无 | 自动生成 (/docs) |
|
|
||||||
| 可扩展性 / Extensibility | 低 | 高 |
|
|
||||||
|
|
||||||
## 使用方法 / Usage
|
|
||||||
|
|
||||||
### 启动 FastAPI 后端 / Starting FastAPI Backend
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 使用默认配置
|
|
||||||
python gui_fastapi.py
|
|
||||||
|
|
||||||
# 指定主机和端口
|
|
||||||
python gui_fastapi.py --host 0.0.0.0 --port 23467
|
|
||||||
|
|
||||||
# 使用密码保护
|
|
||||||
python gui_fastapi.py --key your_password
|
|
||||||
```
|
|
||||||
|
|
||||||
### 启动原有 PyWebIO 后端 / Starting Original PyWebIO Backend
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python gui.py
|
|
||||||
```
|
|
||||||
|
|
||||||
## API 端点 / API Endpoints
|
|
||||||
|
|
||||||
### 配置管理 / Configuration Management
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 获取所有实例列表
|
|
||||||
GET /api/config/instances
|
|
||||||
|
|
||||||
# 获取特定实例的配置
|
|
||||||
GET /api/config/{instance_name}
|
|
||||||
|
|
||||||
# 更新配置
|
|
||||||
POST /api/config/{instance_name}
|
|
||||||
Body: [{"path": "TaskName.GroupName.SettingName", "value": "new_value"}]
|
|
||||||
|
|
||||||
# 创建新实例
|
|
||||||
POST /api/config/create?name=new_instance©_from=template-aas
|
|
||||||
```
|
|
||||||
|
|
||||||
### 进程管理 / Process Management
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 获取所有进程状态
|
|
||||||
GET /api/process/
|
|
||||||
|
|
||||||
# 获取特定进程状态
|
|
||||||
GET /api/process/{instance_name}/status
|
|
||||||
|
|
||||||
# 启动进程
|
|
||||||
POST /api/process/{instance_name}/start
|
|
||||||
|
|
||||||
# 停止进程
|
|
||||||
POST /api/process/{instance_name}/stop
|
|
||||||
|
|
||||||
# 重启进程
|
|
||||||
POST /api/process/{instance_name}/restart
|
|
||||||
```
|
|
||||||
|
|
||||||
### 系统管理 / System Management
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 获取系统信息
|
|
||||||
GET /api/system/info
|
|
||||||
|
|
||||||
# 设置语言
|
|
||||||
POST /api/system/language
|
|
||||||
Body: {"language": "zh-CN"}
|
|
||||||
|
|
||||||
# 设置主题
|
|
||||||
POST /api/system/theme
|
|
||||||
Body: {"theme": "dark"}
|
|
||||||
|
|
||||||
# 检查更新
|
|
||||||
POST /api/system/update/check
|
|
||||||
|
|
||||||
# 执行更新
|
|
||||||
POST /api/system/update/run
|
|
||||||
```
|
|
||||||
|
|
||||||
### WebSocket
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
// 连接到特定实例的日志流
|
|
||||||
const ws = new WebSocket('ws://localhost:23467/ws/logs/aas');
|
|
||||||
|
|
||||||
ws.onmessage = (event) => {
|
|
||||||
const data = JSON.parse(event.data);
|
|
||||||
console.log(data);
|
|
||||||
};
|
|
||||||
|
|
||||||
// 系统级 WebSocket
|
|
||||||
const sysWs = new WebSocket('ws://localhost:23467/ws/system');
|
|
||||||
```
|
|
||||||
|
|
||||||
## 前端界面 / Frontend Interface
|
|
||||||
|
|
||||||
### 布局 / Layout
|
|
||||||
|
|
||||||
新界面采用网格布局,分为四个主要区域:
|
|
||||||
|
|
||||||
The new interface uses a grid layout with four main areas:
|
|
||||||
|
|
||||||
1. **Header** (顶部) - 标题和状态指示器
|
|
||||||
2. **Aside** (左侧) - 实例导航
|
|
||||||
3. **Menu** (中左) - 功能菜单
|
|
||||||
4. **Content** (主要内容区) - 内容显示
|
|
||||||
|
|
||||||
### 样式 / Styling
|
|
||||||
|
|
||||||
前端复用了原有的 CSS 文件以保持一致的视觉风格:
|
|
||||||
|
|
||||||
The frontend reuses the original CSS files to maintain consistent styling:
|
|
||||||
|
|
||||||
- `assets/gui/css/alas.css` - 基础样式
|
|
||||||
- `assets/gui/css/alas-pc.css` - 桌面端样式
|
|
||||||
- `assets/gui/css/light-alas.css` - 浅色主题
|
|
||||||
- `assets/gui/css/dark-alas.css` - 深色主题
|
|
||||||
|
|
||||||
## 功能对比 / Feature Comparison
|
|
||||||
|
|
||||||
### 已实现 / Implemented ✅
|
|
||||||
|
|
||||||
- [x] 实例列表和选择
|
|
||||||
- [x] 进程控制 (启动/停止/重启)
|
|
||||||
- [x] 系统信息显示
|
|
||||||
- [x] 语言切换
|
|
||||||
- [x] 主题切换
|
|
||||||
- [x] WebSocket 日志流
|
|
||||||
- [x] REST API 端点
|
|
||||||
- [x] API 文档 (/docs)
|
|
||||||
|
|
||||||
### 待完善 / To Be Completed 🚧
|
|
||||||
|
|
||||||
- [ ] 完整的配置编辑器
|
|
||||||
- [ ] 任务调度可视化
|
|
||||||
- [ ] 日志过滤和搜索
|
|
||||||
- [ ] 更新系统界面
|
|
||||||
- [ ] 远程访问管理界面
|
|
||||||
- [ ] 移动端响应式优化
|
|
||||||
|
|
||||||
## 开发指南 / Development Guide
|
|
||||||
|
|
||||||
### 添加新的 API 端点 / Adding New API Endpoints
|
|
||||||
|
|
||||||
1. 在 `module/webui/fastapi_backend/routes/` 中创建或修改文件
|
|
||||||
2. 定义 Pydantic 模型用于请求/响应验证
|
|
||||||
3. 在 `main.py` 中注册路由器
|
|
||||||
|
|
||||||
示例 / Example:
|
|
||||||
|
|
||||||
```python
|
|
||||||
# routes/my_feature.py
|
|
||||||
from fastapi import APIRouter
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
router = APIRouter()
|
|
||||||
|
|
||||||
class MyRequest(BaseModel):
|
|
||||||
value: str
|
|
||||||
|
|
||||||
@router.post("/my-endpoint")
|
|
||||||
async def my_endpoint(request: MyRequest):
|
|
||||||
return {"status": "success", "received": request.value}
|
|
||||||
|
|
||||||
# main.py
|
|
||||||
from module.webui.fastapi_backend.routes import my_feature
|
|
||||||
app.include_router(my_feature.router, prefix="/api/my-feature", tags=["my-feature"])
|
|
||||||
```
|
|
||||||
|
|
||||||
### 修改前端 / Modifying Frontend
|
|
||||||
|
|
||||||
主要的前端文件:
|
|
||||||
|
|
||||||
Main frontend file:
|
|
||||||
|
|
||||||
- `module/webui/fastapi_backend/templates/index.html`
|
|
||||||
|
|
||||||
可以添加新的模板文件或静态资源到:
|
|
||||||
|
|
||||||
You can add new templates or static assets to:
|
|
||||||
|
|
||||||
- `module/webui/fastapi_backend/templates/`
|
|
||||||
- `module/webui/fastapi_backend/static/`
|
|
||||||
|
|
||||||
## 迁移建议 / Migration Recommendations
|
|
||||||
|
|
||||||
### 对于最终用户 / For End Users
|
|
||||||
|
|
||||||
1. **渐进式迁移** / **Gradual Migration**
|
|
||||||
- 继续使用 `python gui.py` 运行原有界面
|
|
||||||
- 尝试 `python gui_fastapi.py` 体验新界面
|
|
||||||
- 当新界面功能完善后再切换
|
|
||||||
|
|
||||||
2. **配置兼容** / **Config Compatibility**
|
|
||||||
- 两个界面共享相同的配置文件
|
|
||||||
- 切换界面不会丢失配置
|
|
||||||
|
|
||||||
### 对于开发者 / For Developers
|
|
||||||
|
|
||||||
1. **API 优先** / **API First**
|
|
||||||
- 使用 REST API 开发新功能
|
|
||||||
- 可以为移动端、CLI 等创建新客户端
|
|
||||||
|
|
||||||
2. **逐步迁移功能** / **Gradual Feature Migration**
|
|
||||||
- 从简单功能开始迁移
|
|
||||||
- 每个功能独立测试
|
|
||||||
- 保持与原有功能的兼容
|
|
||||||
|
|
||||||
## 故障排除 / Troubleshooting
|
|
||||||
|
|
||||||
### 常见问题 / Common Issues
|
|
||||||
|
|
||||||
1. **端口被占用** / **Port Already in Use**
|
|
||||||
```bash
|
|
||||||
python gui_fastapi.py --port 23468
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **依赖缺失** / **Missing Dependencies**
|
|
||||||
```bash
|
|
||||||
pip install fastapi>=0.100.0 starlette>=0.27.0 uvicorn>=0.20.0 jinja2>=3.0.0
|
|
||||||
```
|
|
||||||
|
|
||||||
3. **WebSocket 连接失败** / **WebSocket Connection Failed**
|
|
||||||
- 检查防火墙设置
|
|
||||||
- 确保使用正确的协议 (ws:// 或 wss://)
|
|
||||||
|
|
||||||
4. **样式显示异常** / **Styling Issues**
|
|
||||||
- 清除浏览器缓存
|
|
||||||
- 检查 CSS 文件路径是否正确
|
|
||||||
|
|
||||||
## 技术栈 / Technology Stack
|
|
||||||
|
|
||||||
### 后端 / Backend
|
|
||||||
- FastAPI >= 0.100.0
|
|
||||||
- Starlette >= 0.27.0
|
|
||||||
- Uvicorn >= 0.20.0
|
|
||||||
- Pydantic
|
|
||||||
- Python 3.10+
|
|
||||||
|
|
||||||
### 前端 / Frontend
|
|
||||||
- HTML5
|
|
||||||
- CSS3 (Bootstrap 5)
|
|
||||||
- Vanilla JavaScript
|
|
||||||
- WebSocket API
|
|
||||||
|
|
||||||
## 性能对比 / Performance Comparison
|
|
||||||
|
|
||||||
| 指标 / Metric | PyWebIO | FastAPI |
|
|
||||||
|--------------|---------|---------|
|
|
||||||
| 启动时间 / Startup | ~2s | ~1s |
|
|
||||||
| API 响应 / API Response | N/A | <50ms |
|
|
||||||
| 内存占用 / Memory | ~100MB | ~80MB |
|
|
||||||
| 并发支持 / Concurrency | 有限 | 优秀 |
|
|
||||||
|
|
||||||
## 贡献 / Contributing
|
|
||||||
|
|
||||||
欢迎贡献代码!以下是一些可以改进的方向:
|
|
||||||
|
|
||||||
Contributions are welcome! Here are some areas for improvement:
|
|
||||||
|
|
||||||
1. 完善配置编辑器 / Complete config editor
|
|
||||||
2. 增强日志查看器 / Enhanced log viewer
|
|
||||||
3. 移动端适配 / Mobile responsiveness
|
|
||||||
4. 国际化改进 / i18n improvements
|
|
||||||
5. 单元测试 / Unit tests
|
|
||||||
6. 文档完善 / Documentation
|
|
||||||
|
|
||||||
## 反馈 / Feedback
|
|
||||||
|
|
||||||
如果遇到问题或有建议,请:
|
|
||||||
|
|
||||||
If you encounter issues or have suggestions:
|
|
||||||
|
|
||||||
1. 在 GitHub 上创建 Issue
|
|
||||||
2. 提供详细的错误信息和日志
|
|
||||||
3. 说明使用的 Python 版本和操作系统
|
|
||||||
|
|
||||||
## 许可 / License
|
|
||||||
|
|
||||||
本项目遵循与主项目相同的许可协议。
|
|
||||||
|
|
||||||
This follows the same license as the main project.
|
|
||||||
@@ -8,7 +8,6 @@ from MCE.custom_widgets.ctk_timeentry import CTkTimeEntry
|
|||||||
from MCE.custom_widgets.ctk_integerspinbox import CTkIntegerSpinbox
|
from MCE.custom_widgets.ctk_integerspinbox import CTkIntegerSpinbox
|
||||||
from MCE.custom_widgets.ctk_templatedialog import CTkTemplateDialog
|
from MCE.custom_widgets.ctk_templatedialog import CTkTemplateDialog
|
||||||
from MCE.custom_widgets.ctk_notification import CTkNotification
|
from MCE.custom_widgets.ctk_notification import CTkNotification
|
||||||
from MCE.custom_widgets.ctk_add_button import CTkAddButton
|
|
||||||
from MCE.utils import Linker, Config
|
from MCE.utils import Linker, Config
|
||||||
from filelock import FileLock, Timeout
|
from filelock import FileLock, Timeout
|
||||||
import threading
|
import threading
|
||||||
@@ -118,7 +117,7 @@ class MCE_Manager(customtkinter.CTk):
|
|||||||
|
|
||||||
# Helper method to create Mission Tabview with Template and Queue Tabs
|
# Helper method to create Mission Tabview with Template and Queue Tabs
|
||||||
def create_mission_tabview(self):
|
def create_mission_tabview(self):
|
||||||
self.mission_tabview = customtkinter.CTkTabview(self)
|
self.mission_tabview = customtkinter.CTkTabview(self, height=500)
|
||||||
self.mission_tabview.grid(row=17, column=0, columnspan=3, padx=20)
|
self.mission_tabview.grid(row=17, column=0, columnspan=3, padx=20)
|
||||||
|
|
||||||
self.tab_template = self.mission_tabview.add('Template')
|
self.tab_template = self.mission_tabview.add('Template')
|
||||||
@@ -139,7 +138,7 @@ class MCE_Manager(customtkinter.CTk):
|
|||||||
self.mode_label.grid(row=1, column=0, padx=(130, 0), pady=5)
|
self.mode_label.grid(row=1, column=0, padx=(130, 0), pady=5)
|
||||||
|
|
||||||
self.stage_label = customtkinter.CTkLabel(self.template_labels, text="Stage:", font=customtkinter.CTkFont(underline=True))
|
self.stage_label = customtkinter.CTkLabel(self.template_labels, text="Stage:", font=customtkinter.CTkFont(underline=True))
|
||||||
self.stage_tooltip = CTkToolTip(self.stage_label, message="Valid format\nMission: 1-1, 3-A\nCommissions & Event: 01", justify=tk.LEFT)
|
self.stage_tooltip = CTkToolTip(self.stage_label, message="Valid format for Mission: 1-1\nValid format for Commissions/Event: 01")
|
||||||
self.stage_label.grid(row=1, column=1, padx=(40, 20), pady=5)
|
self.stage_label.grid(row=1, column=1, padx=(40, 20), pady=5)
|
||||||
|
|
||||||
self.run_times_label = customtkinter.CTkLabel(self.template_labels, text="Number of Sweeps:", font=customtkinter.CTkFont(underline=True))
|
self.run_times_label = customtkinter.CTkLabel(self.template_labels, text="Number of Sweeps:", font=customtkinter.CTkFont(underline=True))
|
||||||
@@ -152,8 +151,7 @@ class MCE_Manager(customtkinter.CTk):
|
|||||||
self.highlight_label = customtkinter.CTkLabel(self.template_buttons_frame, text="*You can double click an entry and press up or down arrow to change its position", font=customtkinter.CTkFont(family="Inter", size=12))
|
self.highlight_label = customtkinter.CTkLabel(self.template_buttons_frame, text="*You can double click an entry and press up or down arrow to change its position", font=customtkinter.CTkFont(family="Inter", size=12))
|
||||||
self.highlight_label.grid(row=0, column=0, columnspan=3)
|
self.highlight_label.grid(row=0, column=0, columnspan=3)
|
||||||
|
|
||||||
self.add_button = CTkAddButton(master=self.template_buttons_frame)
|
self.add_button = customtkinter.CTkButton(self.template_buttons_frame , text="Add", command=lambda queue=queue: self.add_frame(queue=queue))
|
||||||
self.add_button.button.configure(command=lambda queue=queue, button=self.add_button.button: self.add_frame(queue=queue, button=button))
|
|
||||||
self.add_button.grid(row=1, column=0, padx=5, pady=5)
|
self.add_button.grid(row=1, column=0, padx=5, pady=5)
|
||||||
|
|
||||||
# Clear button to clear all frames
|
# Clear button to clear all frames
|
||||||
@@ -168,10 +166,10 @@ class MCE_Manager(customtkinter.CTk):
|
|||||||
|
|
||||||
# Helper method to create Template Frame and Queue Frame
|
# Helper method to create Template Frame and Queue Frame
|
||||||
def create_template_and_queue_frames(self):
|
def create_template_and_queue_frames(self):
|
||||||
self.template_frame = customtkinter.CTkScrollableFrame(self.tab_template, width=435, height=350)
|
self.template_frame = customtkinter.CTkScrollableFrame(self.tab_template, width=400, height=350)
|
||||||
self.template_frame.grid(row=1, column=0, sticky="nsew")
|
self.template_frame.grid(row=1, column=0, sticky="nsew")
|
||||||
|
|
||||||
self.queue_frame = customtkinter.CTkScrollableFrame(self.tab_queue, width=435, height=350)
|
self.queue_frame = customtkinter.CTkScrollableFrame(self.tab_queue, width=400, height=350)
|
||||||
self.queue_frame.grid(row=1, column=0, sticky="nsew")
|
self.queue_frame.grid(row=1, column=0, sticky="nsew")
|
||||||
|
|
||||||
# Helper method to create Lists to Store Frame Widgets
|
# Helper method to create Lists to Store Frame Widgets
|
||||||
@@ -213,7 +211,7 @@ class MCE_Manager(customtkinter.CTk):
|
|||||||
self.template_optionmenu.set(self.previous_selected)
|
self.template_optionmenu.set(self.previous_selected)
|
||||||
return
|
return
|
||||||
elif template_name in self.templates_list:
|
elif template_name in self.templates_list:
|
||||||
CTkMessagebox(title="Error", message="Name is invalid.", icon="MCE\icons\cancel.png")
|
CTkMessagebox(title="Error", message="Name is invalid.", icon="cancel")
|
||||||
self.template_optionmenu.set(self.previous_selected)
|
self.template_optionmenu.set(self.previous_selected)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@@ -234,7 +232,7 @@ class MCE_Manager(customtkinter.CTk):
|
|||||||
|
|
||||||
def delete_template(self):
|
def delete_template(self):
|
||||||
msg = CTkMessagebox(title="Template Deletetion", message=f"Are you sure you want to delete Template {self.previous_selected}?",
|
msg = CTkMessagebox(title="Template Deletetion", message=f"Are you sure you want to delete Template {self.previous_selected}?",
|
||||||
icon="MCE\icons\question.png", option_1="No", option_2="Yes")
|
icon="question", option_1="No", option_2="Yes")
|
||||||
response = msg.get()
|
response = msg.get()
|
||||||
if response=="Yes":
|
if response=="Yes":
|
||||||
if len(self.templates) != 1:
|
if len(self.templates) != 1:
|
||||||
@@ -252,19 +250,18 @@ class MCE_Manager(customtkinter.CTk):
|
|||||||
self.template_optionmenu.configure(values=self.templates_list)
|
self.template_optionmenu.configure(values=self.templates_list)
|
||||||
self.template_optionmenu.set(self.preferred_template)
|
self.template_optionmenu.set(self.preferred_template)
|
||||||
else:
|
else:
|
||||||
CTkMessagebox(title="Error", message="At least one template must exist!!!", icon="MCE\icons\cancel.png")
|
CTkMessagebox(title="Error", message="At least one template must exist!!!", icon="cancel")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Function to add a frame with widgets
|
# Function to add a frame with widgets
|
||||||
def add_frame(self, inner_list=None, queue=False, state="normal", button=None):
|
def add_frame(self, inner_list=None, queue=False, state="normal"):
|
||||||
position = button.cget("text") if button else "Add Down"
|
|
||||||
frames = self.queue_frames if queue else self.template_frames
|
frames = self.queue_frames if queue else self.template_frames
|
||||||
parent_frame = self.queue_frame if queue else self.template_frame
|
parent_frame = self.queue_frame if queue else self.template_frame
|
||||||
row_index = len(frames) + 1 # Calculate the row for the new frame
|
row_index = len(frames) + 1 # Calculate the row for the new frame
|
||||||
# Create a frame
|
# Create a frame
|
||||||
frame = tk.Frame(parent_frame, bg="gray17")
|
frame = tk.Frame(parent_frame, bg="gray17")
|
||||||
frame.grid(row=row_index, column=0, columnspan=4, padx=10, pady=10, sticky="w")
|
frame.grid(row=row_index, column=0, columnspan=4, padx=10, pady=10, sticky="w")
|
||||||
frames.append(frame) if position == "Add Down" else frames.insert(0, frame)
|
frames.append(frame)
|
||||||
# "Up" button to move the frame up
|
# "Up" button to move the frame up
|
||||||
up_button = customtkinter.CTkButton(frame, text="Up", width=5, command=lambda f=frame, queue=queue: self.move_frame_up(f, queue), state=state)
|
up_button = customtkinter.CTkButton(frame, text="Up", width=5, command=lambda f=frame, queue=queue: self.move_frame_up(f, queue), state=state)
|
||||||
up_button.grid(row=0, column=0, padx=5, pady=5, sticky="w")
|
up_button.grid(row=0, column=0, padx=5, pady=5, sticky="w")
|
||||||
@@ -291,9 +288,7 @@ class MCE_Manager(customtkinter.CTk):
|
|||||||
delete_button = customtkinter.CTkButton(frame, text="Delete", width=5, command=lambda f=frame, queue=queue: self.delete_frame(f, queue), state=state)
|
delete_button = customtkinter.CTkButton(frame, text="Delete", width=5, command=lambda f=frame, queue=queue: self.delete_frame(f, queue), state=state)
|
||||||
delete_button.grid(row=0, column=5, padx=5, pady=5, sticky="w")
|
delete_button.grid(row=0, column=5, padx=5, pady=5, sticky="w")
|
||||||
|
|
||||||
frame.bind("<Double-Button-1>", lambda event, f=frame: self.highlight_frame(f))
|
frame.bind("<Double-Button-1>", lambda event, f=frame: self.highlight_frame(f))
|
||||||
if position == "Add Up":
|
|
||||||
self.update_frame_positions(queue=queue)
|
|
||||||
|
|
||||||
# Function to clear all frames
|
# Function to clear all frames
|
||||||
def clear_frames(self, queue=False):
|
def clear_frames(self, queue=False):
|
||||||
@@ -311,7 +306,7 @@ class MCE_Manager(customtkinter.CTk):
|
|||||||
mode_optionmenu = frame.winfo_children()[2]
|
mode_optionmenu = frame.winfo_children()[2]
|
||||||
stage_entry = frame.winfo_children()[3]
|
stage_entry = frame.winfo_children()[3]
|
||||||
if not self.check_entry(mode_optionmenu, stage_entry):
|
if not self.check_entry(mode_optionmenu, stage_entry):
|
||||||
CTkMessagebox(title="Error", message="Configuration not saved. Some entries are incomplete or have incorect input.", icon="MCE\icons\cancel.png")
|
CTkMessagebox(title="Error", message="Configuration not saved. Some entries are incomplete or have incorect input.", icon="cancel")
|
||||||
return
|
return
|
||||||
mode = frame.winfo_children()[2].get()
|
mode = frame.winfo_children()[2].get()
|
||||||
stage = frame.winfo_children()[3].get().strip()
|
stage = frame.winfo_children()[3].get().strip()
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
import customtkinter
|
|
||||||
|
|
||||||
class CTkAddButton(customtkinter.CTkFrame):
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
self.button = customtkinter.CTkButton(self, text="Add Down", corner_radius=0, width=120)
|
|
||||||
self.button.grid(row=0, column=0)
|
|
||||||
self.option_menu = customtkinter.CTkOptionMenu(
|
|
||||||
self, values= ["Add Up", "Add Down"], width=10, command=self.set_button, corner_radius=0
|
|
||||||
)
|
|
||||||
self.option_menu.set("")
|
|
||||||
self.option_menu.grid(row=0, column=1)
|
|
||||||
|
|
||||||
def set_button(self, value):
|
|
||||||
self.option_menu.set("")
|
|
||||||
self.button.configure(text=value)
|
|
||||||
|
|
||||||
def configure(self, *args, **kwargs):
|
|
||||||
self.button.configure(*args, **kwargs)
|
|
||||||
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
@@ -29,33 +29,6 @@
|
|||||||
- [x] 日语
|
- [x] 日语
|
||||||
- [x] 英语
|
- [x] 英语
|
||||||
|
|
||||||
## WebUI 界面
|
|
||||||
|
|
||||||
项目提供两种 WebUI 后端选项:
|
|
||||||
|
|
||||||
### FastAPI 后端(推荐/新)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python gui_fastapi.py
|
|
||||||
```
|
|
||||||
|
|
||||||
- ✅ 现代化 REST API 架构
|
|
||||||
- ✅ 完整的 API 文档 (`/docs`)
|
|
||||||
- ✅ WebSocket 实时日志
|
|
||||||
- ✅ 更好的扩展性
|
|
||||||
- ✅ 保持与原界面一致的样式
|
|
||||||
|
|
||||||
### PyWebIO 后端(传统)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python gui.py
|
|
||||||
```
|
|
||||||
|
|
||||||
- 原有的 WebUI 实现
|
|
||||||
- 功能完整且稳定
|
|
||||||
|
|
||||||
详细说明请参阅 [FastAPI 迁移指南](FASTAPI_MIGRATION.md)
|
|
||||||
|
|
||||||
## 已知问题
|
## 已知问题
|
||||||
|
|
||||||
若愿意提供其他语言或国服支持,请开 PR 或 Issue。
|
若愿意提供其他语言或国服支持,请开 PR 或 Issue。
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.9 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 5.3 KiB |
@@ -377,7 +377,6 @@ pre.rich-traceback-code {
|
|||||||
#pywebio-scope-scheduler-bar,
|
#pywebio-scope-scheduler-bar,
|
||||||
#pywebio-scope-log-bar,
|
#pywebio-scope-log-bar,
|
||||||
#pywebio-scope-log,
|
#pywebio-scope-log,
|
||||||
#pywebio-scope-daemon-log-bar,
|
|
||||||
#pywebio-scope-daemon-overview #pywebio-scope-groups {
|
#pywebio-scope-daemon-overview #pywebio-scope-groups {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin: 0.3125rem;
|
margin: 0.3125rem;
|
||||||
|
|||||||
@@ -133,13 +133,12 @@ pre.rich-traceback-code {
|
|||||||
color: #c9d1d9;
|
color: #c9d1d9;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pywebio-scope-running,
|
|
||||||
#pywebio-scope-pending,
|
|
||||||
#pywebio-scope-waiting,
|
|
||||||
#pywebio-scope-scheduler-bar,
|
#pywebio-scope-scheduler-bar,
|
||||||
#pywebio-scope-log-bar,
|
#pywebio-scope-log-bar,
|
||||||
#pywebio-scope-log,
|
#pywebio-scope-log,
|
||||||
#pywebio-scope-daemon-log-bar,
|
#pywebio-scope-running,
|
||||||
|
#pywebio-scope-pending,
|
||||||
|
#pywebio-scope-waiting,
|
||||||
#pywebio-scope-daemon-overview #pywebio-scope-groups {
|
#pywebio-scope-daemon-overview #pywebio-scope-groups {
|
||||||
background-color: #2f3136;
|
background-color: #2f3136;
|
||||||
border: 1px solid #21262d;
|
border: 1px solid #21262d;
|
||||||
|
|||||||
@@ -133,13 +133,12 @@ pre.rich-traceback-code {
|
|||||||
border: 1px solid lightgrey;
|
border: 1px solid lightgrey;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pywebio-scope-running,
|
|
||||||
#pywebio-scope-pending,
|
|
||||||
#pywebio-scope-waiting,
|
|
||||||
#pywebio-scope-scheduler-bar,
|
#pywebio-scope-scheduler-bar,
|
||||||
#pywebio-scope-log-bar,
|
#pywebio-scope-log-bar,
|
||||||
#pywebio-scope-log,
|
#pywebio-scope-log,
|
||||||
#pywebio-scope-daemon-log-bar,
|
#pywebio-scope-running,
|
||||||
|
#pywebio-scope-pending,
|
||||||
|
#pywebio-scope-waiting,
|
||||||
#pywebio-scope-daemon-overview #pywebio-scope-groups {
|
#pywebio-scope-daemon-overview #pywebio-scope-groups {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border: 1px solid lightgrey;
|
border: 1px solid lightgrey;
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 148 KiB |
|
Before Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 88 KiB |