继续优化深色模式显示
This commit is contained in:
@@ -16,6 +16,45 @@ if TYPE_CHECKING:
|
||||
from pqAutomationApp import PQAutomationApp
|
||||
|
||||
|
||||
def _result_bg_color() -> str:
|
||||
"""根据当前主题返回结果图背景色。"""
|
||||
try:
|
||||
from app.views.theme_manager import is_dark
|
||||
return "#1B1F24" if is_dark() else "#FFFFFF"
|
||||
except Exception:
|
||||
return "#FFFFFF"
|
||||
|
||||
|
||||
def apply_result_chart_theme(self: "PQAutomationApp"):
|
||||
"""统一刷新结果图画布背景,使其跟随浅/深色主题。"""
|
||||
bg = _result_bg_color()
|
||||
|
||||
chart_pairs = [
|
||||
("gamut_fig", "gamut_canvas"),
|
||||
("gamma_fig", "gamma_canvas"),
|
||||
("eotf_fig", "eotf_canvas"),
|
||||
("cct_fig", "cct_canvas"),
|
||||
("contrast_fig", "contrast_canvas"),
|
||||
("accuracy_fig", "accuracy_canvas"),
|
||||
]
|
||||
|
||||
for fig_attr, canvas_attr in chart_pairs:
|
||||
fig = getattr(self, fig_attr, None)
|
||||
canvas = getattr(self, canvas_attr, None)
|
||||
if fig is not None:
|
||||
fig.patch.set_facecolor(bg)
|
||||
if canvas is not None:
|
||||
try:
|
||||
widget = canvas.get_tk_widget()
|
||||
widget.configure(bg=bg, highlightthickness=0)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
canvas.draw_idle()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def init_gamut_chart(self: "PQAutomationApp"):
|
||||
"""初始化色域图表 - 手动设置subplot位置,完全避免重叠"""
|
||||
container = ttk.Frame(self.gamut_chart_frame)
|
||||
@@ -988,6 +1027,7 @@ def create_result_chart_frame(self: "PQAutomationApp"):
|
||||
self.init_cct_chart()
|
||||
self.init_contrast_chart()
|
||||
self.init_accuracy_chart()
|
||||
self.apply_result_chart_theme()
|
||||
|
||||
# 绑定Tab切换事件
|
||||
self.chart_notebook.bind("<<NotebookTabChanged>>", self.on_chart_tab_changed)
|
||||
@@ -1026,6 +1066,7 @@ class ChartFrameMixin:
|
||||
init_cct_chart = init_cct_chart
|
||||
init_contrast_chart = init_contrast_chart
|
||||
init_accuracy_chart = init_accuracy_chart
|
||||
apply_result_chart_theme = apply_result_chart_theme
|
||||
_init_accuracy_result_table = _init_accuracy_result_table
|
||||
clear_accuracy_result_table = clear_accuracy_result_table
|
||||
update_accuracy_result_table = update_accuracy_result_table
|
||||
|
||||
@@ -20,6 +20,21 @@ if TYPE_CHECKING:
|
||||
from pqAutomationApp import PQAutomationApp
|
||||
|
||||
|
||||
def _theme_colors():
|
||||
style = ttk.Style()
|
||||
colors = style.colors
|
||||
return {
|
||||
"bg": colors.bg,
|
||||
"fg": colors.fg,
|
||||
"muted": colors.secondary,
|
||||
"input_bg": colors.inputbg,
|
||||
"input_fg": colors.inputfg,
|
||||
"select_bg": colors.selectbg,
|
||||
"select_fg": colors.selectfg,
|
||||
"border": colors.border,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -50,6 +65,7 @@ def create_ai_image_panel(self: "PQAutomationApp"):
|
||||
container.columnconfigure(0, weight=0)
|
||||
container.columnconfigure(1, weight=1)
|
||||
container.rowconfigure(0, weight=1)
|
||||
palette = _theme_colors()
|
||||
|
||||
left = ttk.Frame(container, width=360)
|
||||
left.grid(row=0, column=0, sticky=tk.NS, padx=(0, 10))
|
||||
@@ -72,10 +88,12 @@ def create_ai_image_panel(self: "PQAutomationApp"):
|
||||
bd=1,
|
||||
relief=tk.FLAT,
|
||||
highlightthickness=1,
|
||||
highlightbackground="#d8d8d8",
|
||||
highlightcolor="#4a90e2",
|
||||
selectbackground="#2b6cb0",
|
||||
selectforeground="#ffffff",
|
||||
bg=palette["input_bg"],
|
||||
fg=palette["input_fg"],
|
||||
highlightbackground=palette["border"],
|
||||
highlightcolor=palette["select_bg"],
|
||||
selectbackground=palette["select_bg"],
|
||||
selectforeground=palette["select_fg"],
|
||||
yscrollcommand=scroll.set,
|
||||
)
|
||||
scroll.config(command=self.ai_image_listbox.yview)
|
||||
@@ -135,7 +153,7 @@ def create_ai_image_panel(self: "PQAutomationApp"):
|
||||
preview_frame.pack(fill=tk.BOTH, expand=True)
|
||||
|
||||
self.ai_image_canvas = tk.Canvas(
|
||||
preview_frame, bg="#1e1e1e", highlightthickness=0
|
||||
preview_frame, bg=palette["bg"], highlightthickness=0
|
||||
)
|
||||
self.ai_image_canvas.pack(fill=tk.BOTH, expand=True)
|
||||
self.ai_image_canvas.bind("<Configure>", lambda e: _redraw_preview(self))
|
||||
@@ -145,14 +163,21 @@ def create_ai_image_panel(self: "PQAutomationApp"):
|
||||
self.ai_image_meta_var = tk.StringVar(value="未选择图片")
|
||||
ttk.Label(
|
||||
meta_row, textvariable=self.ai_image_meta_var,
|
||||
foreground="#666", font=("微软雅黑", 9),
|
||||
foreground=palette["muted"], font=("微软雅黑", 9),
|
||||
).pack(side=tk.LEFT)
|
||||
|
||||
# 输入区
|
||||
input_frame = ttk.LabelFrame(right, text="提示输入(Ctrl+Enter 发送)", padding=6)
|
||||
input_frame.pack(fill=tk.X, pady=(4, 0))
|
||||
|
||||
self.ai_image_input = tk.Text(input_frame, height=3, wrap=tk.WORD)
|
||||
self.ai_image_input = tk.Text(
|
||||
input_frame,
|
||||
height=3,
|
||||
wrap=tk.WORD,
|
||||
bg=palette["input_bg"],
|
||||
fg=palette["input_fg"],
|
||||
insertbackground=palette["input_fg"],
|
||||
)
|
||||
self.ai_image_input.pack(fill=tk.X, side=tk.TOP)
|
||||
self.ai_image_input.bind("<Control-Return>", lambda e: (_send_prompt(self), "break"))
|
||||
|
||||
@@ -161,7 +186,7 @@ def create_ai_image_panel(self: "PQAutomationApp"):
|
||||
self.ai_image_status_var = tk.StringVar(value="就绪")
|
||||
ttk.Label(
|
||||
send_row, textvariable=self.ai_image_status_var,
|
||||
foreground="#888", font=("微软雅黑", 9),
|
||||
foreground=palette["muted"], font=("微软雅黑", 9),
|
||||
).pack(side=tk.LEFT)
|
||||
self.ai_image_progress = ttk.Progressbar(
|
||||
send_row,
|
||||
@@ -220,6 +245,7 @@ def reload_ai_image_list(self: "PQAutomationApp", auto_select_first=True):
|
||||
其下列出该轮生成的所有图片。会话按"最近使用"倒序,组内按时间倒序。
|
||||
auto_select_first: 是否自动选中第一张图片(默认 True)。
|
||||
"""
|
||||
palette = _theme_colors()
|
||||
self.ai_image_records = _svc.list_records(base_dir=_get_app_base_dir(self))
|
||||
self.ai_image_listbox.delete(0, tk.END)
|
||||
# 维护行号 → 记录索引的映射;分隔头处为 None
|
||||
@@ -236,8 +262,8 @@ def reload_ai_image_list(self: "PQAutomationApp", auto_select_first=True):
|
||||
# 头部行:禁用选中(视觉上变灰)
|
||||
last = self.ai_image_listbox.size() - 1
|
||||
self.ai_image_listbox.itemconfig(
|
||||
last, foreground="#888", selectforeground="#888",
|
||||
background="#f5f5f5", selectbackground="#f5f5f5",
|
||||
last, foreground=palette["muted"], selectforeground=palette["muted"],
|
||||
background=palette["bg"], selectbackground=palette["bg"],
|
||||
)
|
||||
self._ai_image_row_map.append(None)
|
||||
self._ai_image_row_session_map.append(sid)
|
||||
@@ -331,6 +357,7 @@ def _select_record(self: "PQAutomationApp", rec: _svc.AIImageRecord):
|
||||
def _redraw_preview(self: "PQAutomationApp"):
|
||||
rec = getattr(self, "ai_image_current", None)
|
||||
canvas = self.ai_image_canvas
|
||||
palette = _theme_colors()
|
||||
canvas.delete("all")
|
||||
if rec is None or not os.path.isfile(rec.image_path):
|
||||
return
|
||||
@@ -340,7 +367,7 @@ def _redraw_preview(self: "PQAutomationApp"):
|
||||
img = Image.open(rec.image_path)
|
||||
img.load()
|
||||
except Exception as exc:
|
||||
canvas.create_text(cw // 2, ch // 2, text=f"加载失败: {exc}", fill="#f66")
|
||||
canvas.create_text(cw // 2, ch // 2, text=f"加载失败: {exc}", fill=palette["select_bg"])
|
||||
return
|
||||
iw, ih = img.size
|
||||
scale = min(cw / iw, ch / ih, 1.0)
|
||||
|
||||
@@ -14,6 +14,14 @@ if TYPE_CHECKING:
|
||||
from pqAutomationApp import PQAutomationApp
|
||||
|
||||
|
||||
def _theme_colors():
|
||||
style = ttk.Style()
|
||||
colors = style.colors
|
||||
return {
|
||||
"muted": colors.secondary,
|
||||
}
|
||||
|
||||
|
||||
|
||||
def create_cct_params_frame(self: "PQAutomationApp"):
|
||||
"""创建色度参数设置区域 - 屏模组、SDR、HDR 独立(增加色域参考标准选择 + 单步调试按钮)"""
|
||||
@@ -122,7 +130,7 @@ def create_cct_params_frame(self: "PQAutomationApp"):
|
||||
self.cct_params_frame,
|
||||
text="提示: 清空输入框将恢复默认值",
|
||||
font=("SimHei", 8),
|
||||
foreground="gray",
|
||||
foreground=_theme_colors()["muted"],
|
||||
).grid(row=5, column=0, columnspan=4, sticky=tk.W, padx=5, pady=5)
|
||||
|
||||
# ==================== SDR 色度参数 Frame ====================
|
||||
@@ -227,7 +235,7 @@ def create_cct_params_frame(self: "PQAutomationApp"):
|
||||
self.sdr_cct_params_frame,
|
||||
text="提示: 清空输入框将恢复默认值",
|
||||
font=("SimHei", 8),
|
||||
foreground="gray",
|
||||
foreground=_theme_colors()["muted"],
|
||||
).grid(row=5, column=0, columnspan=4, sticky=tk.W, padx=5, pady=5)
|
||||
|
||||
# ==================== HDR 色度参数 Frame ====================
|
||||
@@ -332,7 +340,7 @@ def create_cct_params_frame(self: "PQAutomationApp"):
|
||||
self.hdr_cct_params_frame,
|
||||
text="提示: 清空输入框将恢复默认值",
|
||||
font=("SimHei", 8),
|
||||
foreground="gray",
|
||||
foreground=_theme_colors()["muted"],
|
||||
).grid(row=5, column=0, columnspan=4, sticky=tk.W, padx=5, pady=5)
|
||||
|
||||
|
||||
|
||||
@@ -718,6 +718,11 @@ def _on_toggle_theme(self: "PQAutomationApp") -> None:
|
||||
from app.views.theme_manager import toggle_theme
|
||||
toggle_theme()
|
||||
_refresh_theme_toggle_label(self)
|
||||
if hasattr(self, "apply_result_chart_theme"):
|
||||
try:
|
||||
self.apply_result_chart_theme()
|
||||
except Exception:
|
||||
pass
|
||||
# 同步刷新侧栏选中态(高亮样式跟随新色板)
|
||||
if hasattr(self, "update_sidebar_selection"):
|
||||
try:
|
||||
|
||||
@@ -10,6 +10,18 @@ import threading
|
||||
import time
|
||||
|
||||
|
||||
def _theme_colors():
|
||||
style = ttk.Style()
|
||||
colors = style.colors
|
||||
return {
|
||||
"fg": colors.fg,
|
||||
"muted": colors.secondary,
|
||||
"info": colors.info,
|
||||
"warning": colors.warning,
|
||||
"error": colors.danger,
|
||||
}
|
||||
|
||||
|
||||
class PQDebugPanel:
|
||||
"""PQ 单步调试面板 - 支持 Gamma/EOTF/色准单步测试"""
|
||||
|
||||
@@ -72,7 +84,7 @@ class PQDebugPanel:
|
||||
self.screen_gamma_frame,
|
||||
text="测试完成后可用,选择灰阶进行单步调试",
|
||||
font=("SimHei", 9),
|
||||
foreground="gray",
|
||||
foreground=_theme_colors()["muted"],
|
||||
).grid(row=0, column=0, columnspan=3, pady=(0, 10))
|
||||
|
||||
# 灰阶选择
|
||||
@@ -137,7 +149,7 @@ class PQDebugPanel:
|
||||
self.screen_rgb_frame,
|
||||
text="测试完成后可用,选择颜色进行单步调试",
|
||||
font=("SimHei", 9),
|
||||
foreground="gray",
|
||||
foreground=_theme_colors()["muted"],
|
||||
).grid(row=0, column=0, columnspan=3, pady=(0, 10))
|
||||
|
||||
# RGB 颜色选择
|
||||
@@ -210,7 +222,7 @@ class PQDebugPanel:
|
||||
self.sdr_gamma_frame,
|
||||
text="测试完成后可用,选择灰阶进行单步调试",
|
||||
font=("SimHei", 9),
|
||||
foreground="gray",
|
||||
foreground=_theme_colors()["muted"],
|
||||
).grid(row=0, column=0, columnspan=3, pady=(0, 10))
|
||||
|
||||
ttk.Label(self.sdr_gamma_frame, text="选择灰阶:").grid(
|
||||
@@ -272,7 +284,7 @@ class PQDebugPanel:
|
||||
self.sdr_accuracy_frame,
|
||||
text="测试完成后可用,选择色块进行单步调试",
|
||||
font=("SimHei", 9),
|
||||
foreground="gray",
|
||||
foreground=_theme_colors()["muted"],
|
||||
).grid(row=0, column=0, columnspan=3, pady=(0, 10))
|
||||
|
||||
ttk.Label(self.sdr_accuracy_frame, text="选择色块:").grid(
|
||||
@@ -334,7 +346,7 @@ class PQDebugPanel:
|
||||
self.sdr_rgb_frame,
|
||||
text="测试完成后可用,选择颜色进行单步调试",
|
||||
font=("SimHei", 9),
|
||||
foreground="gray",
|
||||
foreground=_theme_colors()["muted"],
|
||||
).grid(row=0, column=0, columnspan=3, pady=(0, 10))
|
||||
|
||||
# RGB 颜色选择
|
||||
@@ -407,7 +419,7 @@ class PQDebugPanel:
|
||||
self.hdr_eotf_frame,
|
||||
text="测试完成后可用,选择灰阶进行单步调试",
|
||||
font=("SimHei", 9),
|
||||
foreground="gray",
|
||||
foreground=_theme_colors()["muted"],
|
||||
).grid(row=0, column=0, columnspan=3, pady=(0, 10))
|
||||
|
||||
ttk.Label(self.hdr_eotf_frame, text="选择灰阶:").grid(
|
||||
@@ -469,7 +481,7 @@ class PQDebugPanel:
|
||||
self.hdr_accuracy_frame,
|
||||
text="测试完成后可用,选择色块进行单步调试",
|
||||
font=("SimHei", 9),
|
||||
foreground="gray",
|
||||
foreground=_theme_colors()["muted"],
|
||||
).grid(row=0, column=0, columnspan=3, pady=(0, 10))
|
||||
|
||||
ttk.Label(self.hdr_accuracy_frame, text="选择色块:").grid(
|
||||
@@ -531,7 +543,7 @@ class PQDebugPanel:
|
||||
self.hdr_rgb_frame,
|
||||
text="测试完成后可用,选择颜色进行单步调试",
|
||||
font=("SimHei", 9),
|
||||
foreground="gray",
|
||||
foreground=_theme_colors()["muted"],
|
||||
).grid(row=0, column=0, columnspan=3, pady=(0, 10))
|
||||
|
||||
# RGB 颜色选择
|
||||
@@ -1007,12 +1019,13 @@ class PQDebugPanel:
|
||||
)
|
||||
|
||||
# 设置标签样式
|
||||
tree.tag_configure("header", background="#E3F2FD", font=("SimHei", 9, "bold"))
|
||||
tree.tag_configure("normal", foreground="black")
|
||||
tree.tag_configure("warning", foreground="red")
|
||||
tree.tag_configure("highlight", foreground="blue", font=("SimHei", 9, "bold"))
|
||||
palette = _theme_colors()
|
||||
tree.tag_configure("header", background=palette["info"], font=("SimHei", 9, "bold"))
|
||||
tree.tag_configure("normal", foreground=palette["fg"])
|
||||
tree.tag_configure("warning", foreground=palette["warning"])
|
||||
tree.tag_configure("highlight", foreground=palette["info"], font=("SimHei", 9, "bold"))
|
||||
tree.tag_configure(
|
||||
"highlight_warning", foreground="red", font=("SimHei", 9, "bold")
|
||||
"highlight_warning", foreground=palette["warning"], font=("SimHei", 9, "bold")
|
||||
)
|
||||
|
||||
def _disable_test_button(self, test_type, test_item):
|
||||
|
||||
@@ -17,6 +17,22 @@ _GUI_LEVEL_TO_LOG = {
|
||||
}
|
||||
|
||||
|
||||
def _theme_colors():
|
||||
style = ttk.Style()
|
||||
colors = style.colors
|
||||
return {
|
||||
"bg": colors.bg,
|
||||
"fg": colors.fg,
|
||||
"muted": colors.secondary,
|
||||
"accent": colors.info,
|
||||
"warning": colors.warning,
|
||||
"error": colors.danger,
|
||||
"success": colors.success,
|
||||
"text_bg": colors.inputbg,
|
||||
"text_fg": colors.inputfg,
|
||||
}
|
||||
|
||||
|
||||
class PQLogGUI(ttk.Frame):
|
||||
VALID_LEVELS = {"info", "success", "warning", "error", "debug", "separator", "blank"}
|
||||
|
||||
@@ -53,21 +69,22 @@ class PQLogGUI(ttk.Frame):
|
||||
text_container = ttk.Frame(log_frame)
|
||||
text_container.pack(fill=tk.BOTH, expand=True, padx=6, pady=(0, 6))
|
||||
|
||||
palette = _theme_colors()
|
||||
self.log_text = tk.Text(
|
||||
text_container,
|
||||
height=10,
|
||||
width=50,
|
||||
wrap=tk.WORD,
|
||||
font=("Consolas", 10),
|
||||
bg="#fbfcfe",
|
||||
fg="#1f2937",
|
||||
bg=palette["text_bg"],
|
||||
fg=palette["text_fg"],
|
||||
relief=tk.FLAT,
|
||||
bd=0,
|
||||
padx=10,
|
||||
pady=8,
|
||||
spacing1=2,
|
||||
spacing3=2,
|
||||
insertbackground="#1f2937",
|
||||
insertbackground=palette["text_fg"],
|
||||
)
|
||||
self.log_text.pack(fill=tk.BOTH, expand=True, side=tk.LEFT)
|
||||
|
||||
@@ -114,19 +131,20 @@ class PQLogGUI(ttk.Frame):
|
||||
self._update_summary()
|
||||
|
||||
def _configure_tags(self):
|
||||
self.log_text.tag_configure("timestamp", foreground="#6b7280")
|
||||
self.log_text.tag_configure("level_info", foreground="#2563eb")
|
||||
self.log_text.tag_configure("level_success", foreground="#0f766e")
|
||||
self.log_text.tag_configure("level_warning", foreground="#b45309")
|
||||
self.log_text.tag_configure("level_error", foreground="#b91c1c")
|
||||
palette = _theme_colors()
|
||||
self.log_text.tag_configure("timestamp", foreground=palette["muted"])
|
||||
self.log_text.tag_configure("level_info", foreground=palette["accent"])
|
||||
self.log_text.tag_configure("level_success", foreground=palette["success"])
|
||||
self.log_text.tag_configure("level_warning", foreground=palette["warning"])
|
||||
self.log_text.tag_configure("level_error", foreground=palette["error"])
|
||||
self.log_text.tag_configure("level_debug", foreground="#7c3aed")
|
||||
self.log_text.tag_configure("message", foreground="#1f2937")
|
||||
self.log_text.tag_configure("message_success", foreground="#0f766e")
|
||||
self.log_text.tag_configure("message_warning", foreground="#b45309")
|
||||
self.log_text.tag_configure("message_error", foreground="#991b1b")
|
||||
self.log_text.tag_configure("message", foreground=palette["fg"])
|
||||
self.log_text.tag_configure("message_success", foreground=palette["success"])
|
||||
self.log_text.tag_configure("message_warning", foreground=palette["warning"])
|
||||
self.log_text.tag_configure("message_error", foreground=palette["error"])
|
||||
self.log_text.tag_configure("message_debug", foreground="#6d28d9")
|
||||
self.log_text.tag_configure("separator", foreground="#94a3b8")
|
||||
self.log_text.tag_configure("traceback", foreground="#7f1d1d")
|
||||
self.log_text.tag_configure("separator", foreground=palette["muted"])
|
||||
self.log_text.tag_configure("traceback", foreground=palette["error"])
|
||||
self.log_text.tag_configure("blank", spacing1=4, spacing3=4)
|
||||
|
||||
def _append_message(self, message, level):
|
||||
|
||||
Reference in New Issue
Block a user