修改Calman灰阶中结果图显示、修改UI主题样式应用

This commit is contained in:
xinzhu.yin
2026-06-04 10:36:15 +08:00
parent 3aa975c4d3
commit 49d82da8b9
16 changed files with 597 additions and 210 deletions

View File

@@ -13,6 +13,8 @@ from tkinter import filedialog, messagebox
import ttkbootstrap as ttk
from PIL import Image
from app.views.modern_styles import apply_listbox_theme
from typing import TYPE_CHECKING
if TYPE_CHECKING:
@@ -59,7 +61,7 @@ def create_single_step_panel(self: "PQAutomationApp"):
ttk.Label(
title_row,
text="录入目标色块,发送纯色色块并采集 xyY / ΔE2000。",
foreground="#666",
style="Muted.TLabel",
).pack(side=tk.LEFT, padx=(12, 0))
left = ttk.LabelFrame(root, text="样本列表", padding=8)
@@ -73,11 +75,8 @@ def create_single_step_panel(self: "PQAutomationApp"):
activestyle="none",
font=("微软雅黑", 9),
highlightthickness=1,
highlightbackground="#d8d8d8",
highlightcolor="#4a90e2",
selectbackground="#2b6cb0",
selectforeground="#ffffff",
)
apply_listbox_theme(self.single_step_listbox)
self.single_step_listbox.pack(fill=tk.BOTH, expand=True)
self.single_step_listbox.bind(
"<<ListboxSelect>>", lambda e: _on_sample_select(self)
@@ -154,7 +153,7 @@ def create_single_step_panel(self: "PQAutomationApp"):
ttk.Label(
form_frame,
textvariable=self.single_step_status_var,
foreground="#666",
style="Muted.TLabel",
).grid(row=2, column=2, columnspan=4, sticky=tk.W, pady=4)
action_row = ttk.Frame(form_frame)
@@ -444,7 +443,7 @@ def _measure_current_sample(self: "PQAutomationApp"):
def worker():
try:
x, y, lv, _X, _Y, _Z = self.ca.readAllDisplay()
x, y, lv, _X, _Y, _Z = self.read_ca_xyLv()
if lv is None:
raise RuntimeError("CA410 未返回有效亮度")
self._dispatch_ui(self.single_step_measured_x_var.set, f"{x:.4f}")
@@ -556,6 +555,12 @@ def _export_results_csv(self: "PQAutomationApp"):
messagebox.showerror("导出失败", f"写入 CSV 失败: {exc}")
def refresh_single_step_theme(self: "PQAutomationApp"):
"""刷新单步调试中 tk.Listbox 的主题色。"""
if hasattr(self, "single_step_listbox"):
apply_listbox_theme(self.single_step_listbox)
class SingleStepPanelMixin:
"""由 tools/refactor_to_mixins.py 自动生成。
把本模块的自由函数挂到 PQAutomationApp 上,便于 F12 跳转与类型推断。
@@ -575,3 +580,4 @@ class SingleStepPanelMixin:
_commit_result = _commit_result
_clear_results = _clear_results
_export_results_csv = _export_results_csv
refresh_single_step_theme = refresh_single_step_theme