feat: add Production ID input widget and UI configuration
- Add ProductionIdInput widget with placeholder and multi-line support - Add UIConfig class for font family, font size, and input width settings - Refactor data extraction tab to use horizontal PanedWindow layout - Left panel: Production ID text input (draggable width) - Right panel: control panel and log output - Share Production IDs between data extraction and material validation tabs - Add UI settings group in settings page (font selection, size, input width) - For User users: automatically use shared Production IDs, simplified UI - Apply font settings to input and log widgets - Use sashpos() to set initial pane width correctly Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,7 @@ class MainWindow:
|
||||
self.root = root
|
||||
self.config = ConfigManager()
|
||||
self.session_manager = session_manager
|
||||
self.shared_production_ids = [] # 共享的 Production ID 列表
|
||||
|
||||
# 设置窗口属性(包含用户信息)
|
||||
user_type_display = "管理员" if session_manager.is_admin() else "用户"
|
||||
@@ -49,6 +50,18 @@ class MainWindow:
|
||||
# 居中窗口
|
||||
self._center_window()
|
||||
|
||||
def get_shared_production_ids(self) -> list:
|
||||
"""获取共享的 Production ID 列表"""
|
||||
return self.shared_production_ids.copy()
|
||||
|
||||
def update_shared_production_ids(self, production_ids: list):
|
||||
"""更新共享的 Production ID 列表"""
|
||||
self.shared_production_ids = production_ids
|
||||
# 通知物料校验标签页 Production ID 已更新
|
||||
if hasattr(self, 'validation_tab'):
|
||||
if hasattr(self.validation_tab, 'on_production_ids_updated'):
|
||||
self.validation_tab.on_production_ids_updated(production_ids)
|
||||
|
||||
def create_menu(self):
|
||||
"""创建菜单栏"""
|
||||
menubar = tk.Menu(self.root)
|
||||
@@ -70,18 +83,31 @@ class MainWindow:
|
||||
self.notebook = ttk.Notebook(self.root)
|
||||
self.notebook.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
|
||||
|
||||
# 数据提取标签页
|
||||
self.extraction_tab = DataExtractionTab(self.notebook, self.config)
|
||||
# 数据提取标签页(传递 self 以支持共享 Production ID)
|
||||
self.extraction_tab = DataExtractionTab(self.notebook, self.config, self)
|
||||
self.notebook.add(self.extraction_tab, text="数据提取")
|
||||
|
||||
# 物料校验标签页(传入 session_manager)
|
||||
self.validation_tab = MaterialValidationTab(self.notebook, self.config, self.session_manager)
|
||||
# 物料校验标签页(传入 session_manager 和 main_window)
|
||||
self.validation_tab = MaterialValidationTab(self.notebook, self.config, self.session_manager, self)
|
||||
self.notebook.add(self.validation_tab, text="物料校验")
|
||||
|
||||
# 设置标签页(传入 session_manager)
|
||||
self.settings_tab = SettingsTab(self.notebook, self.config, self.session_manager)
|
||||
self.notebook.add(self.settings_tab, text="设置")
|
||||
|
||||
# 初始化:如果数据提取页面已有 Production ID,通知物料校验页面
|
||||
self._initialize_shared_production_ids()
|
||||
|
||||
def _initialize_shared_production_ids(self):
|
||||
"""初始化共享的 Production ID(从数据提取页面获取)"""
|
||||
try:
|
||||
if hasattr(self.extraction_tab, 'production_id_input'):
|
||||
production_ids = self.extraction_tab.production_id_input.get()
|
||||
if production_ids:
|
||||
self.update_shared_production_ids(production_ids)
|
||||
except Exception:
|
||||
pass # 如果获取失败,忽略错误
|
||||
|
||||
def create_status_bar(self):
|
||||
"""创建状态栏"""
|
||||
self.status_bar = ttk.Frame(self.root, relief=tk.SUNKEN)
|
||||
@@ -144,3 +170,17 @@ class MainWindow:
|
||||
"• 数据库持久化 - 将提取的数据自动保存到数据库\n\n"
|
||||
"基于 Playwright 和 Python 开发",
|
||||
)
|
||||
|
||||
def reload_config(self):
|
||||
"""配置更新后重新加载配置到各个标签页"""
|
||||
# 重新加载配置
|
||||
self.config.reload()
|
||||
|
||||
# 通知各个标签页重新加载配置
|
||||
if hasattr(self.extraction_tab, 'reload_config'):
|
||||
self.extraction_tab.reload_config()
|
||||
if hasattr(self.validation_tab, 'reload_config'):
|
||||
self.validation_tab.reload_config()
|
||||
|
||||
# 更新状态栏
|
||||
self.config_status.set("配置已重新加载")
|
||||
|
||||
Reference in New Issue
Block a user