修改引用逻辑、新增Pattern更改界面、新增Calman灰阶界面
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""自定义模板结果面板(Step 6 重构)。"""
|
||||
"""自定义模板结果面板(Step 6 重构)。"""
|
||||
|
||||
import threading
|
||||
import time
|
||||
@@ -11,7 +11,13 @@ import numpy as np
|
||||
|
||||
from app.data_range_converter import convert_pattern_params
|
||||
|
||||
def create_custom_template_result_panel(self):
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pqAutomationApp import PQAutomationApp
|
||||
|
||||
|
||||
def create_custom_template_result_panel(self: "PQAutomationApp"):
|
||||
"""创建客户模板结果显示区域(黑底表格)"""
|
||||
self.custom_result_frame = ttk.LabelFrame(
|
||||
self.custom_template_tab_frame, text="客户模板结果显示"
|
||||
@@ -151,7 +157,7 @@ def create_custom_template_result_panel(self):
|
||||
table_container.grid_columnconfigure(0, weight=1)
|
||||
|
||||
|
||||
def show_custom_result_context_menu(self, event):
|
||||
def show_custom_result_context_menu(self: "PQAutomationApp", event):
|
||||
"""显示客户模板结果右键菜单"""
|
||||
if not hasattr(self, "custom_result_tree") or not hasattr(
|
||||
self, "custom_result_menu"
|
||||
@@ -197,7 +203,7 @@ def show_custom_result_context_menu(self, event):
|
||||
self.custom_result_menu.grab_release()
|
||||
|
||||
|
||||
def set_custom_result_table_locked(self, locked):
|
||||
def set_custom_result_table_locked(self: "PQAutomationApp", locked):
|
||||
"""锁定/解锁客户模板结果表(测试期间禁选择、禁右键)"""
|
||||
if not hasattr(self, "custom_result_tree"):
|
||||
return
|
||||
@@ -208,7 +214,7 @@ def set_custom_result_table_locked(self, locked):
|
||||
pass
|
||||
|
||||
|
||||
def start_custom_row_single_step(self):
|
||||
def start_custom_row_single_step(self: "PQAutomationApp"):
|
||||
"""单步测试当前选中行:发送该行 pattern 并覆盖该行测量结果"""
|
||||
if not hasattr(self, "custom_result_tree"):
|
||||
return
|
||||
@@ -252,7 +258,7 @@ def start_custom_row_single_step(self):
|
||||
).start()
|
||||
|
||||
|
||||
def _clear_custom_result_row(self, item_id, row_no):
|
||||
def _clear_custom_result_row(self: "PQAutomationApp", item_id, row_no):
|
||||
"""单步测试开始前清空指定行的测量数据"""
|
||||
if not hasattr(self, "custom_result_tree"):
|
||||
return
|
||||
@@ -281,7 +287,7 @@ def _clear_custom_result_row(self, item_id, row_no):
|
||||
self.custom_result_tree.see(item_id)
|
||||
|
||||
|
||||
def _run_custom_row_single_step(self, item_id, row_no):
|
||||
def _run_custom_row_single_step(self: "PQAutomationApp", item_id, row_no):
|
||||
"""后台执行客户模板单步测试"""
|
||||
try:
|
||||
self._dispatch_ui(self.status_var.set, f"单步测试第 {row_no} 行...")
|
||||
@@ -352,7 +358,7 @@ def _run_custom_row_single_step(self, item_id, row_no):
|
||||
self._dispatch_ui(self.status_var.set, "单步测试失败")
|
||||
|
||||
|
||||
def _update_custom_result_row(self, item_id, row_no, result_data):
|
||||
def _update_custom_result_row(self: "PQAutomationApp", item_id, row_no, result_data):
|
||||
"""覆盖更新客户模板结果表中指定行"""
|
||||
|
||||
def fmt(value, digits=4):
|
||||
@@ -394,7 +400,7 @@ def _update_custom_result_row(self, item_id, row_no, result_data):
|
||||
self.custom_result_tree.item(item_id, values=new_values)
|
||||
|
||||
|
||||
def copy_custom_result_table(self):
|
||||
def copy_custom_result_table(self: "PQAutomationApp"):
|
||||
"""复制客户模板结果表格到剪贴板(不含标题行/No./Pattern)"""
|
||||
if not hasattr(self, "custom_result_tree"):
|
||||
return
|
||||
@@ -434,7 +440,7 @@ def copy_custom_result_table(self):
|
||||
if hasattr(self, "log_gui"):
|
||||
self.log_gui.log(f"已复制客户模板表格数据({len(items)} 行)", level="success")
|
||||
|
||||
def clear_custom_template_results(self):
|
||||
def clear_custom_template_results(self: "PQAutomationApp"):
|
||||
"""清空客户模板结果表格"""
|
||||
if not hasattr(self, "custom_result_tree"):
|
||||
return
|
||||
@@ -442,7 +448,7 @@ def clear_custom_template_results(self):
|
||||
self.custom_result_tree.delete(item)
|
||||
|
||||
|
||||
def auto_expand_custom_result_view(self):
|
||||
def auto_expand_custom_result_view(self: "PQAutomationApp"):
|
||||
"""当客户模板表格有数据时,自动扩展窗口以尽量完整显示所有列"""
|
||||
if not hasattr(self, "custom_result_tree"):
|
||||
return
|
||||
@@ -480,7 +486,7 @@ def auto_expand_custom_result_view(self):
|
||||
self.log_gui.log(f"自动扩展客户模板窗口失败: {str(e)}", level="error")
|
||||
|
||||
|
||||
def append_custom_template_result(self, row_no, result_data):
|
||||
def append_custom_template_result(self: "PQAutomationApp", row_no, result_data):
|
||||
"""追加一条客户模板结果到表格"""
|
||||
|
||||
def fmt(value, digits=4):
|
||||
@@ -523,7 +529,7 @@ def append_custom_template_result(self, row_no, result_data):
|
||||
self.auto_expand_custom_result_view()
|
||||
|
||||
|
||||
def start_custom_template_test(self):
|
||||
def start_custom_template_test(self: "PQAutomationApp"):
|
||||
"""开始客户模板测试(SDR)"""
|
||||
|
||||
if hasattr(self, "chart_notebook") and hasattr(self, "custom_template_tab_frame"):
|
||||
@@ -571,7 +577,7 @@ def start_custom_template_test(self):
|
||||
self.test_thread.daemon = True
|
||||
self.test_thread.start()
|
||||
|
||||
def update_custom_button_visibility(self):
|
||||
def update_custom_button_visibility(self: "PQAutomationApp"):
|
||||
"""只在 SDR 测试时显示客户模版按钮"""
|
||||
if not hasattr(self, "custom_btn") or not hasattr(self, "test_type_var"):
|
||||
return
|
||||
@@ -625,7 +631,7 @@ def update_custom_button_visibility(self):
|
||||
# self.log_gui.log("已填充 147 行客户模板测试数据", level="success")
|
||||
|
||||
|
||||
def export_custom_template_excel(self):
|
||||
def export_custom_template_excel(self: "PQAutomationApp"):
|
||||
"""将客户模板结果表导出为 Excel 文件(14 列完整数据)"""
|
||||
if not hasattr(self, "custom_result_tree"):
|
||||
return
|
||||
@@ -773,7 +779,7 @@ def export_custom_template_excel(self):
|
||||
messagebox.showerror("错误", f"导出失败:{str(e)}")
|
||||
|
||||
|
||||
def export_custom_template_charts(self):
|
||||
def export_custom_template_charts(self: "PQAutomationApp"):
|
||||
"""生成客户模板图表:xy 色度散点图 + Lv 亮度曲线图,保存为 PNG"""
|
||||
if not hasattr(self, "custom_result_tree"):
|
||||
return
|
||||
@@ -910,3 +916,24 @@ def export_custom_template_charts(self):
|
||||
if hasattr(self, "log_gui"):
|
||||
self.log_gui.log(f"生成图表失败: {str(e)}", level="error")
|
||||
messagebox.showerror("错误", f"生成图表失败:{str(e)}")
|
||||
|
||||
|
||||
class CustomTemplatePanelMixin:
|
||||
"""由 tools/refactor_to_mixins.py 自动生成。
|
||||
把本模块的自由函数挂到 PQAutomationApp 上,便于 F12 跳转与类型推断。
|
||||
"""
|
||||
create_custom_template_result_panel = create_custom_template_result_panel
|
||||
show_custom_result_context_menu = show_custom_result_context_menu
|
||||
set_custom_result_table_locked = set_custom_result_table_locked
|
||||
start_custom_row_single_step = start_custom_row_single_step
|
||||
_clear_custom_result_row = _clear_custom_result_row
|
||||
_run_custom_row_single_step = _run_custom_row_single_step
|
||||
_update_custom_result_row = _update_custom_result_row
|
||||
copy_custom_result_table = copy_custom_result_table
|
||||
clear_custom_template_results = clear_custom_template_results
|
||||
auto_expand_custom_result_view = auto_expand_custom_result_view
|
||||
append_custom_template_result = append_custom_template_result
|
||||
start_custom_template_test = start_custom_template_test
|
||||
update_custom_button_visibility = update_custom_button_visibility
|
||||
export_custom_template_excel = export_custom_template_excel
|
||||
export_custom_template_charts = export_custom_template_charts
|
||||
|
||||
Reference in New Issue
Block a user