修改日志/细节问题

This commit is contained in:
xinzhu.yin
2026-04-21 16:03:11 +08:00
parent e27312d0a3
commit 9a2ac69afb
14 changed files with 230 additions and 144 deletions

View File

@@ -94,7 +94,7 @@ def create_cct_params_frame(self):
text="打开调试面板",
command=self.toggle_screen_debug_panel,
bootstyle="info-outline",
# state=tk.DISABLED, # 初始禁用
state=tk.DISABLED, # 初始禁用
width=15,
)
self.screen_debug_btn.grid(row=1, column=3, sticky=tk.W, padx=5, pady=3)
@@ -211,7 +211,7 @@ def create_cct_params_frame(self):
text="打开调试面板",
command=self.toggle_sdr_debug_panel,
bootstyle="info-outline",
# state=tk.DISABLED, # 初始禁用
state=tk.DISABLED, # 初始禁用
width=15,
)
self.sdr_debug_btn.grid(row=1, column=3, sticky=tk.W, padx=5, pady=3)
@@ -328,7 +328,7 @@ def create_cct_params_frame(self):
text="打开调试面板",
command=self.toggle_hdr_debug_panel,
bootstyle="info-outline",
# state=tk.DISABLED, # 初始禁用
state=tk.DISABLED, # 初始禁用
width=15,
)
self.hdr_debug_btn.grid(row=1, column=3, sticky=tk.W, padx=5, pady=3)
@@ -405,9 +405,9 @@ def _save_cct_params_for(self, test_type):
"""保存指定测试类型的 CCT 参数。"""
try:
default_params = self.config.get_default_cct_params(test_type)
var_dict = self._get_cct_var_dict(test_type)
var_dict = _get_cct_var_dict(test_type)
cct_params = {
key: self._parse_cct_float(var_dict[key], default_params[key])
key: _parse_cct_float(var_dict[key], default_params[key])
for key in default_params
}
@@ -452,22 +452,22 @@ def _handle_cct_focus_out(self, var, default_value, save_func, label):
def on_sdr_cct_param_focus_out(self, var, default_value):
"""SDR 色度参数失去焦点时的处理。"""
self._handle_cct_focus_out(var, default_value, self.save_sdr_cct_params, "SDR")
_handle_cct_focus_out(var, default_value, self.save_sdr_cct_params, "SDR")
def save_sdr_cct_params(self):
"""保存 SDR 色度参数。"""
self._save_cct_params_for("sdr_movie")
_save_cct_params_for("sdr_movie")
def on_hdr_cct_param_focus_out(self, var, default_value):
"""HDR 色度参数失去焦点时的处理。"""
self._handle_cct_focus_out(var, default_value, self.save_hdr_cct_params, "HDR")
_handle_cct_focus_out(var, default_value, self.save_hdr_cct_params, "HDR")
def save_hdr_cct_params(self):
"""保存 HDR 色度参数。"""
self._save_cct_params_for("hdr_movie")
_save_cct_params_for("hdr_movie")
def recalculate_cct(self):
@@ -527,7 +527,7 @@ def recalculate_cct(self):
messagebox.showinfo("成功", "色度图已根据新参数重新绘制!")
except Exception as e:
self.log_gui.log(f"[Error] 重新计算失败: {str(e)}", level="error")
self.log_gui.log(f"重新计算失败: {str(e)}", level="error")
self.log_gui.log(traceback.format_exc(), level="error")
messagebox.showerror("错误", f"重新计算失败: {str(e)}")
@@ -675,19 +675,19 @@ def recalculate_gamut(self):
)
except Exception as e:
self.log_gui.log(f"[Error] 重新计算失败: {str(e)}", level="error")
self.log_gui.log(f"重新计算失败: {str(e)}", level="error")
self.log_gui.log(traceback.format_exc(), level="error")
messagebox.showerror("错误", f"重新计算失败: {str(e)}")
def on_cct_param_focus_out(self, var, default_value):
"""色度参数失去焦点时的处理 - 空值恢复默认"""
self._handle_cct_focus_out(var, default_value, self.save_cct_params, "屏模组")
_handle_cct_focus_out(var, default_value, self.save_cct_params, "屏模组")
def save_cct_params(self):
"""保存色度参数 - 简化版"""
self._save_cct_params_for(self.config.current_test_type)
_save_cct_params_for(self.config.current_test_type)
def reload_cct_params(self):
@@ -743,7 +743,7 @@ def toggle_cct_params_frame(self):
self.hdr_cct_params_frame.pack(fill=tk.X, padx=5, pady=5)
else:
if hasattr(self, "log_gui"):
self.log_gui.log("[ERROR] HDR 色度参数框尚未创建", level="error")
self.log_gui.log("HDR 色度参数框尚未创建", level="error")
# ---- gamut 参考标准改变回调(统一实现) ----

View File

@@ -232,10 +232,10 @@ def start_custom_row_single_step(self):
children = list(self.custom_result_tree.get_children())
row_no = children.index(item_id) + 1 if item_id in children else 1
self._clear_custom_result_row(item_id, row_no)
_clear_custom_result_row(item_id, row_no)
threading.Thread(
target=self._run_custom_row_single_step,
target=_run_custom_row_single_step,
args=(item_id, row_no),
daemon=True,
).start()
@@ -295,7 +295,7 @@ def _run_custom_row_single_step(self, item_id, row_no):
)
if row_no > len(converted_params):
self.log_gui.log(f"[Error] 行号超出 pattern 范围: {row_no}/{len(converted_params)}", level="error")
self.log_gui.log(f"行号超出 pattern 范围: {row_no}/{len(converted_params)}", level="error")
self._dispatch_ui(self.status_var.set, "单步测试失败:行号超范围")
return
@@ -332,14 +332,14 @@ def _run_custom_row_single_step(self, item_id, row_no):
}
self._dispatch_ui(
self._update_custom_result_row, item_id, row_no, row_data
_update_custom_result_row, item_id, row_no, row_data
)
self.log_gui.log(f"{row_no} 行单步测试完成并已覆盖", level="success")
self._dispatch_ui(self.status_var.set, f"{row_no} 行单步测试完成")
except Exception as e:
self.log_gui.log(f"[Error] 单步测试失败: {str(e)}", level="error")
self.log_gui.log(f"单步测试失败: {str(e)}", level="error")
self._dispatch_ui(self.status_var.set, "单步测试失败")
@@ -425,49 +425,6 @@ def copy_custom_result_table(self):
if hasattr(self, "log_gui"):
self.log_gui.log(f"已复制客户模板表格数据({len(items)} 行)", level="success")
def fill_custom_result_test_data(self):
"""填充 147 行客户模板测试数据(用于界面验证)"""
if not hasattr(self, "custom_result_tree"):
return
self.clear_custom_template_results()
pattern_names = []
if hasattr(self, "config") and hasattr(self.config, "get_temp_pattern_names"):
pattern_names = self.config.get_temp_pattern_names()
total_rows = 147
for i in range(1, total_rows + 1):
ratio = (i - 1) / (total_rows - 1) if total_rows > 1 else 0
row_data = {
"pattern_name": (
pattern_names[i - 1] if i - 1 < len(pattern_names) else f"P {i}"
),
"X": 0.8 + ratio * 120,
"Y": 0.9 + ratio * 135,
"Z": 1.1 + ratio * 145,
"x": 0.24 + ratio * 0.10,
"y": 0.26 + ratio * 0.10,
"Lv": 1.0 + ratio * 500,
"u_prime": 0.16 + ratio * 0.12,
"v_prime": 0.42 + ratio * 0.08,
"Tcp": 1800 + ratio * 12000,
"duv": -0.01 + ratio * 0.03,
"lambda_d": 430 + ratio * 200,
"Pe": 10 + ratio * 90,
}
self.append_custom_template_result(i, row_data)
if hasattr(self, "chart_notebook") and hasattr(self, "custom_template_tab_frame"):
self.chart_notebook.select(self.custom_template_tab_frame)
if hasattr(self, "status_var"):
self.status_var.set("已填充 147 行客户模板测试数据")
if hasattr(self, "log_gui"):
self.log_gui.log("已填充 147 行客户模板测试数据", level="success")
def clear_custom_template_results(self):
"""清空客户模板结果表格"""
if not hasattr(self, "custom_result_tree"):
@@ -615,3 +572,45 @@ def update_custom_button_visibility(self):
else:
if self.custom_btn.winfo_manager():
self.custom_btn.pack_forget()
# def fill_custom_result_test_data(self):
# """填充 147 行客户模板测试数据(用于界面验证)"""
# if not hasattr(self, "custom_result_tree"):
# return
# self.clear_custom_template_results()
# pattern_names = []
# if hasattr(self, "config") and hasattr(self.config, "get_temp_pattern_names"):
# pattern_names = self.config.get_temp_pattern_names()
# total_rows = 147
# for i in range(1, total_rows + 1):
# ratio = (i - 1) / (total_rows - 1) if total_rows > 1 else 0
# row_data = {
# "pattern_name": (
# pattern_names[i - 1] if i - 1 < len(pattern_names) else f"P {i}"
# ),
# "X": 0.8 + ratio * 120,
# "Y": 0.9 + ratio * 135,
# "Z": 1.1 + ratio * 145,
# "x": 0.24 + ratio * 0.10,
# "y": 0.26 + ratio * 0.10,
# "Lv": 1.0 + ratio * 500,
# "u_prime": 0.16 + ratio * 0.12,
# "v_prime": 0.42 + ratio * 0.08,
# "Tcp": 1800 + ratio * 12000,
# "duv": -0.01 + ratio * 0.03,
# "lambda_d": 430 + ratio * 200,
# "Pe": 10 + ratio * 90,
# }
# self.append_custom_template_result(i, row_data)
# if hasattr(self, "chart_notebook") and hasattr(self, "custom_template_tab_frame"):
# self.chart_notebook.select(self.custom_template_tab_frame)
# if hasattr(self, "status_var"):
# self.status_var.set("已填充 147 行客户模板测试数据")
# if hasattr(self, "log_gui"):
# self.log_gui.log("已填充 147 行客户模板测试数据", level="success")

View File

@@ -544,7 +544,7 @@ def on_screen_module_timing_changed(self, event=None):
self.save_pq_config()
except Exception as e:
self.log_gui.log(f"[Error] 屏模组信号格式更改失败: {str(e)}", level="error")
self.log_gui.log(f"屏模组信号格式更改失败: {str(e)}", level="error")
def update_test_items(self):

View File

@@ -1,4 +1,4 @@
"""侧边面板(日志 / Local Dimming / 调试)Step 6 重构)。"""
"""侧边面板(日志 / Local Dimming / 调试)"""
import traceback
import tkinter as tk
@@ -258,9 +258,11 @@ def _toggle_debug_panel(self, test_type):
try:
selected_items = self.get_selected_test_items()
dlp = cfg["data_log_prefix"]
results_obj = getattr(self, "results", None)
# 显式按 test_type 拿历史结果,避免依赖"当前活跃"状态
results_store = getattr(self, "results", None)
results_obj = results_store.get(test_type) if results_store is not None else None
if results_obj is None:
self.log_gui.log(f"{dlp} 暂无可用测试结果,面板已打开", level="warning")
self.log_gui.log(f"{dlp} 暂无 {test_type}测试结果,面板已打开", level="warning")
else:
for item_key, debug_key, (cat, sub), data_label, enable_desc in cfg["data_items"]:
if item_key not in selected_items:
@@ -268,11 +270,10 @@ def _toggle_debug_panel(self, test_type):
data = results_obj.get_intermediate_data(cat, sub)
if not data:
if test_type == "screen_module" and item_key == "gamma":
self.log_gui.log("[Error] 没有可用的灰阶数据", level="error")
self.log_gui.log("没有可用的灰阶数据", level="error")
continue
self.log_gui.log(f" → 加载 {len(data)}{data_label}数据点", level="info")
debug_panel_instance.enable_debug(test_type, debug_key, data)
self.log_gui.log(f"{dlp} {enable_desc}已重新启用", level="success")
except Exception as e:
self.log_gui.log(f"加载{cfg['failure_data_label']}失败: {str(e)}", level="error")
self.log_gui.log(traceback.format_exc(), level="error")
@@ -282,13 +283,10 @@ def _toggle_debug_panel(self, test_type):
def on_closing():
btn.config(text="打开调试面板")
getattr(self, win_attr).destroy()
self.log_gui.log(f"{wlp}单步调试窗口已关闭", level="success")
win.protocol("WM_DELETE_WINDOW", on_closing)
win.update_idletasks()
self.log_gui.log(f"{wlp}单步调试面板已打开(独立窗口)", level="success")
def toggle_screen_debug_panel(self):
_toggle_debug_panel(self, "screen_module")