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:
@@ -57,10 +57,11 @@ class SettingsTab(ttk.Frame):
|
||||
self._create_paths_group(scrollable_frame)
|
||||
self._create_extraction_group(scrollable_frame)
|
||||
self._create_validation_group(scrollable_frame)
|
||||
self._create_ui_group(scrollable_frame)
|
||||
|
||||
# 按钮区域 - 根据用户类型显示不同按钮
|
||||
button_frame = ttk.Frame(scrollable_frame)
|
||||
button_frame.grid(row=6, column=0, columnspan=2, pady=20, sticky="ew")
|
||||
button_frame.grid(row=7, column=0, columnspan=2, pady=20, sticky="ew")
|
||||
|
||||
if is_user_only:
|
||||
# 普通用户只显示测试按钮
|
||||
@@ -331,6 +332,39 @@ class SettingsTab(ttk.Frame):
|
||||
|
||||
group.columnconfigure(1, weight=1)
|
||||
|
||||
def _create_ui_group(self, parent):
|
||||
"""创建 UI 配置组"""
|
||||
group = ttk.LabelFrame(parent, text="界面设置", padding=10)
|
||||
group.grid(row=5, column=0, columnspan=2, pady=10, padx=10, sticky="ew")
|
||||
|
||||
# 字体选择
|
||||
ttk.Label(group, text="字体:").grid(row=0, column=0, sticky="w", pady=5)
|
||||
self.ui_font_family_var = tk.StringVar()
|
||||
font_combo = ttk.Combobox(
|
||||
group,
|
||||
textvariable=self.ui_font_family_var,
|
||||
values=["Microsoft YaHei UI", "SimSun", "KaiTi", "FangSong", "Arial", "Segoe UI"],
|
||||
state="readonly",
|
||||
width=30,
|
||||
)
|
||||
font_combo.grid(row=0, column=1, sticky="w", pady=5)
|
||||
|
||||
# 字号选择
|
||||
ttk.Label(group, text="字号:").grid(row=1, column=0, sticky="w", pady=5)
|
||||
self.ui_font_size_var = tk.IntVar(value=10)
|
||||
ttk.Spinbox(
|
||||
group, from_=8, to=24, textvariable=self.ui_font_size_var, width=10
|
||||
).grid(row=1, column=1, sticky="w", pady=5)
|
||||
|
||||
# Production ID 输入框宽度
|
||||
ttk.Label(group, text="输入框宽度(字符):").grid(row=2, column=0, sticky="w", pady=5)
|
||||
self.ui_input_width_var = tk.IntVar(value=20)
|
||||
ttk.Spinbox(
|
||||
group, from_=10, to=100, textvariable=self.ui_input_width_var, width=10
|
||||
).grid(row=2, column=1, sticky="w", pady=5)
|
||||
|
||||
group.columnconfigure(1, weight=1)
|
||||
|
||||
def load_settings(self):
|
||||
"""从配置加载设置到界面"""
|
||||
# 判断是否为仅测试用户模式
|
||||
@@ -391,6 +425,11 @@ class SettingsTab(ttk.Frame):
|
||||
self.validation_enable_crud_var.set(self.config.get("validation.enable_crud_operations", False))
|
||||
self.validation_default_manager_var.set(self.config.get("validation.default_manager", ""))
|
||||
|
||||
# UI 设置
|
||||
self.ui_font_family_var.set(self.config.get("ui.font_family", "Microsoft YaHei UI"))
|
||||
self.ui_font_size_var.set(self.config.get("ui.font_size", 10))
|
||||
self.ui_input_width_var.set(self.config.get("ui.production_id_input_width", 20))
|
||||
|
||||
def save_settings(self):
|
||||
"""保存界面设置到配置"""
|
||||
# ERP 设置
|
||||
@@ -439,12 +478,31 @@ class SettingsTab(ttk.Frame):
|
||||
self.config.set("validation.enable_crud_operations", self.validation_enable_crud_var.get())
|
||||
self.config.set("validation.default_manager", self.validation_default_manager_var.get())
|
||||
|
||||
# UI 设置
|
||||
self.config.set("ui.font_family", self.ui_font_family_var.get())
|
||||
self.config.set("ui.font_size", self.ui_font_size_var.get())
|
||||
self.config.set("ui.production_id_input_width", self.ui_input_width_var.get())
|
||||
|
||||
# 保存到文件
|
||||
if self.config.save():
|
||||
messagebox.showinfo("成功", "设置已保存")
|
||||
# 通知其他标签页重新加载配置
|
||||
self._notify_config_reload()
|
||||
else:
|
||||
messagebox.showerror("错误", "保存设置失败")
|
||||
|
||||
def _notify_config_reload(self):
|
||||
"""通知其他标签页配置已更新"""
|
||||
# 尝试通知主窗口重新加载配置
|
||||
try:
|
||||
# 获取主窗口
|
||||
main_window = self.winfo_toplevel()
|
||||
# 调用主窗口的 reload_config 方法(如果存在)
|
||||
if hasattr(main_window, 'reload_config'):
|
||||
main_window.reload_config()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def test_db_connection(self):
|
||||
"""测试数据库连接"""
|
||||
# 从配置读取而不是从 UI 变量(支持 User 类型用户)
|
||||
|
||||
Reference in New Issue
Block a user