优化UI加载速度

This commit is contained in:
xinzhu.yin
2026-06-22 10:40:39 +08:00
parent 22f8b12690
commit 92cba114a9
9 changed files with 239 additions and 108 deletions

View File

@@ -317,7 +317,7 @@ def _refresh_calman_config_summary(self: "PQAutomationApp") -> None:
def create_calman_panel(self: "PQAutomationApp") -> None:
"""创建 CALMAN 风格灰阶测试面板,注册到 panel_manager。"""
palette = _get_calman_palette()
self.calman_frame = ttk.Frame(self.content_frame)
self.calman_frame = ttk.Frame(self.view_stack)
self.calman_visible = False
self.calman_levels = list(DEFAULT_LEVELS_PCT)
# level_pct -> dict(pct, x, y, Y, X, Z, cct, gamma, de2000, rgb_r, rgb_g, rgb_b, time)
@@ -677,22 +677,45 @@ def create_calman_panel(self: "PQAutomationApp") -> None:
_apply_calman_tree_style(self)
right.bind("<Configure>", lambda _e: _adaptive_matrix_columns(self))
right.bind("<Configure>", lambda _e: _schedule_adaptive_matrix_columns(self))
_refresh_metric_table(self)
_refresh_calman_config_summary(self)
_update_target_strip(self)
_update_actual_strip(self)
_redraw_calman_charts(self)
self.root.after_idle(lambda: _finish_calman_panel_init(self))
# 注册到统一面板管理(按钮稍后由 main_layout 注入)
self.register_panel("calman", self.calman_frame, None, "calman_visible")
def _finish_calman_panel_init(self: "PQAutomationApp") -> None:
"""延迟初始化 CALMAN 图表与表格,避免阻塞主窗口首屏。"""
_refresh_metric_table(self)
_refresh_calman_config_summary(self)
_update_target_strip(self)
_update_actual_strip(self)
_redraw_calman_charts(self)
self._calman_panel_initialized = True
def _on_calman_panel_shown(self: "PQAutomationApp") -> None:
"""面板切到前台时只做轻量刷新,不重绘 Matplotlib。"""
_refresh_calman_config_summary(self)
_schedule_adaptive_matrix_columns(self)
def _schedule_adaptive_matrix_columns(self: "PQAutomationApp") -> None:
job = getattr(self, "_calman_matrix_col_job", None)
if job is not None:
try:
self.root.after_cancel(job)
except Exception:
pass
self._calman_matrix_col_job = self.root.after_idle(
lambda: _adaptive_matrix_columns(self)
)
def toggle_calman_panel(self: "PQAutomationApp") -> None:
"""切换 CALMAN 灰阶面板显示。"""
self.show_panel("calman")
_refresh_calman_config_summary(self)
# ---------------------------------------------------------------------------
@@ -1374,3 +1397,4 @@ class CalmanPanelMixin:
create_calman_panel = create_calman_panel
toggle_calman_panel = toggle_calman_panel
refresh_calman_theme = refresh_calman_theme
_on_calman_panel_shown = _on_calman_panel_shown