refactor: extract common tab functionality to BaseTab and add decorators
- Add BaseTab base class for common tab initialization and logging - Add constants module for shared GUI constants - Move CheckboxTreeview to separate widget file - Add admin_only and require_session decorators to utils.py - Refactor DataExtractionTab and MaterialValidationTab to inherit BaseTab - Remove duplicate _update_log method from tab classes Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
This commit is contained in:
112
gui/constants.py
Normal file
112
gui/constants.py
Normal file
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
GUI 常量模块
|
||||
|
||||
集中管理 GUI 相关的常量配置,包括:
|
||||
- 窗口尺寸
|
||||
- 进度条轮询间隔
|
||||
- 日志颜色
|
||||
- 默认字体配置
|
||||
"""
|
||||
|
||||
# ============================================================================
|
||||
# 窗口尺寸
|
||||
# ============================================================================
|
||||
|
||||
# 主窗口默认尺寸
|
||||
WINDOW_SIZE = (1000, 700)
|
||||
|
||||
# 主窗口最小尺寸
|
||||
MIN_WINDOW_SIZE = (800, 600)
|
||||
|
||||
# 日志面板默认高度(行数)
|
||||
LOG_PANEL_HEIGHT = 15
|
||||
|
||||
# 结果表格默认高度(行数)
|
||||
RESULT_TABLE_HEIGHT = 10
|
||||
|
||||
# ============================================================================
|
||||
# 时间间隔(毫秒)
|
||||
# ============================================================================
|
||||
|
||||
# 进度队列轮询间隔
|
||||
POLL_INTERVAL_MS = 50
|
||||
|
||||
# UI 更新延迟
|
||||
UI_UPDATE_DELAY_MS = 100
|
||||
|
||||
# 标题存储延迟
|
||||
HEADING_STORE_DELAY_MS = 100
|
||||
|
||||
# ============================================================================
|
||||
# 日志颜色
|
||||
# ============================================================================
|
||||
|
||||
# 日志级别对应的颜色
|
||||
LOG_COLORS = {
|
||||
"INFO": "#000000", # 黑色
|
||||
"SUCCESS": "#008000", # 绿色
|
||||
"WARNING": "#FF8C00", # 橙色
|
||||
"ERROR": "#FF0000", # 红色
|
||||
"DEBUG": "#808080", # 灰色
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# 字体配置
|
||||
# ============================================================================
|
||||
|
||||
# 默认字体
|
||||
DEFAULT_FONT_FAMILY = "Microsoft YaHei UI"
|
||||
|
||||
# 默认字号
|
||||
DEFAULT_FONT_SIZE = 10
|
||||
|
||||
# 可用字体列表
|
||||
AVAILABLE_FONTS = [
|
||||
"Microsoft YaHei UI",
|
||||
"SimSun",
|
||||
"KaiTi",
|
||||
"FangSong",
|
||||
"Arial",
|
||||
"Segoe UI",
|
||||
]
|
||||
|
||||
# ============================================================================
|
||||
# 文件类型过滤器
|
||||
# ============================================================================
|
||||
|
||||
# Excel 文件过滤器
|
||||
EXCEL_FILE_TYPES = [("Excel 文件", "*.xlsx"), ("所有文件", "*.*")]
|
||||
|
||||
# 文本文件过滤器
|
||||
TEXT_FILE_TYPES = [("文本文件", "*.txt"), ("所有文件", "*.*")]
|
||||
|
||||
# ============================================================================
|
||||
# 默认值
|
||||
# ============================================================================
|
||||
|
||||
# 默认数据目录
|
||||
DEFAULT_DATA_DIR = "data/"
|
||||
|
||||
# 默认输出文件名
|
||||
DEFAULT_OUTPUT_FILE = "离散备料计划维护_合并.xlsx"
|
||||
|
||||
# 默认校验输出文件名
|
||||
DEFAULT_VALIDATION_OUTPUT = "物料状态校验结果.xlsx"
|
||||
|
||||
# 默认批次大小
|
||||
DEFAULT_BATCH_SIZE = 100
|
||||
|
||||
# 默认数据库批次大小
|
||||
DEFAULT_DB_BATCH_SIZE = 2000
|
||||
|
||||
# ============================================================================
|
||||
# 复选框字符
|
||||
# ============================================================================
|
||||
|
||||
# 选中状态
|
||||
CHECKBOX_CHECKED = "☑"
|
||||
|
||||
# 未选中状态
|
||||
CHECKBOX_UNCHECKED = "☐"
|
||||
Reference in New Issue
Block a user