添加深色模式
This commit is contained in:
@@ -76,17 +76,17 @@ def create_floating_config_panel(self: "PQAutomationApp"):
|
||||
config_row_frame.pack(fill=tk.X, expand=False)
|
||||
|
||||
# 设备连接 卡片
|
||||
connection_card = _make_card(config_row_frame, icon="\U0001F4E1", title="设备连接") # 📡
|
||||
connection_card = _make_card(config_row_frame, icon="01", title="设备连接")
|
||||
connection_card.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=(0, 6))
|
||||
self.connection_frame = connection_card._body # type: ignore[attr-defined]
|
||||
|
||||
# 测试项目 卡片
|
||||
test_items_card = _make_card(config_row_frame, icon="\u2714", title="测试项目") # ✔
|
||||
test_items_card = _make_card(config_row_frame, icon="02", title="测试项目")
|
||||
test_items_card.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=6)
|
||||
self.test_items_frame = test_items_card._body # type: ignore[attr-defined]
|
||||
|
||||
# 信号格式 卡片
|
||||
signal_card = _make_card(config_row_frame, icon="\u2699", title="信号格式") # ⚙
|
||||
signal_card = _make_card(config_row_frame, icon="03", title="信号格式")
|
||||
signal_card.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=(6, 0))
|
||||
self.signal_format_frame = signal_card._body # type: ignore[attr-defined]
|
||||
|
||||
@@ -590,15 +590,37 @@ def create_connection_content(self: "PQAutomationApp"):
|
||||
|
||||
|
||||
def create_test_type_frame(self: "PQAutomationApp"):
|
||||
"""创建测试类型选择区域(侧边栏形式)"""
|
||||
"""创建测试类型选择区域(侧边栏形式)。
|
||||
|
||||
新版(v3)改进:
|
||||
- 深灰分层背景,接近 Calman 的侧栏密度;
|
||||
- 纯文字按钮,不使用 emoji;
|
||||
- 用更克制的字号 / 间距做层级区分;
|
||||
- 不再使用 padding=10 硬覆盖(交给 Sidebar.TButton 样式统一管理)。
|
||||
"""
|
||||
# 设置测试类型变量
|
||||
self.test_type_var = tk.StringVar(value="screen_module")
|
||||
|
||||
# 创建测试类型按钮并放置在侧边栏
|
||||
# ---------- 顶部品牌区 ----------
|
||||
brand = ttk.Frame(self.sidebar_frame, style="SidebarBrand.TFrame")
|
||||
brand.pack(fill=tk.X, pady=(2, 10))
|
||||
ttk.Label(
|
||||
brand,
|
||||
text="PQ AUTOMATION",
|
||||
style="SidebarBrand.TLabel",
|
||||
).pack(side=tk.LEFT, padx=16, pady=11)
|
||||
|
||||
# ---------- 分组:测试类型 ----------
|
||||
ttk.Label(
|
||||
self.sidebar_frame,
|
||||
text="测试类型",
|
||||
style="SidebarSection.TLabel",
|
||||
).pack(fill=tk.X, padx=16, pady=(2, 6), anchor="w")
|
||||
|
||||
test_types = [
|
||||
("屏模组性能测试", "screen_module"),
|
||||
("SDR Movie测试", "sdr_movie"),
|
||||
("HDR Movie测试", "hdr_movie"),
|
||||
("SDR Movie", "sdr_movie"),
|
||||
("HDR Movie", "hdr_movie"),
|
||||
]
|
||||
|
||||
for text, type_value in test_types:
|
||||
@@ -606,87 +628,37 @@ def create_test_type_frame(self: "PQAutomationApp"):
|
||||
master=self.sidebar_frame,
|
||||
text=text,
|
||||
style="Sidebar.TButton",
|
||||
padding=10,
|
||||
command=lambda v=type_value: self.change_test_type(v),
|
||||
takefocus=False,
|
||||
)
|
||||
btn.pack(fill=tk.X, padx=0, pady=1)
|
||||
|
||||
# 保存按钮引用以便后续更新样式
|
||||
setattr(self, f"{type_value}_btn", btn)
|
||||
|
||||
# 添加分隔线
|
||||
ttk.Separator(self.sidebar_frame, orient="horizontal").pack(
|
||||
fill=tk.X, padx=10, pady=10
|
||||
)
|
||||
|
||||
# 只保留日志按钮
|
||||
self.log_btn = ttk.Button(
|
||||
# ---------- 分组:工具面板 ----------
|
||||
ttk.Label(
|
||||
self.sidebar_frame,
|
||||
text="测试日志",
|
||||
style="Sidebar.TButton",
|
||||
command=self.toggle_log_panel,
|
||||
takefocus=False,
|
||||
)
|
||||
self.log_btn.pack(fill=tk.X, padx=0, pady=1)
|
||||
text="工具面板",
|
||||
style="SidebarSection.TLabel",
|
||||
).pack(fill=tk.X, padx=16, pady=(16, 6), anchor="w")
|
||||
|
||||
# Local Dimming 测试按钮
|
||||
self.local_dimming_btn = ttk.Button(
|
||||
self.sidebar_frame,
|
||||
text="Local Dimming",
|
||||
style="Sidebar.TButton",
|
||||
command=self.toggle_local_dimming_panel,
|
||||
takefocus=False,
|
||||
)
|
||||
self.local_dimming_btn.pack(fill=tk.X, padx=0, pady=1)
|
||||
|
||||
# AI 图片对话按钮
|
||||
self.ai_image_btn = ttk.Button(
|
||||
self.sidebar_frame,
|
||||
text="AI 图片",
|
||||
style="Sidebar.TButton",
|
||||
command=self.toggle_ai_image_panel,
|
||||
takefocus=False,
|
||||
)
|
||||
self.ai_image_btn.pack(fill=tk.X, padx=0, pady=1)
|
||||
|
||||
# self.single_step_btn = ttk.Button(
|
||||
# self.sidebar_frame,
|
||||
# text="单步调试",
|
||||
# style="Sidebar.TButton",
|
||||
# command=self.toggle_single_step_panel,
|
||||
# takefocus=False,
|
||||
# )
|
||||
# self.single_step_btn.pack(fill=tk.X, padx=0, pady=1)
|
||||
|
||||
self.pantone_baseline_btn = ttk.Button(
|
||||
self.sidebar_frame,
|
||||
text="Pantone认证摸底测试",
|
||||
style="Sidebar.TButton",
|
||||
command=self.toggle_pantone_baseline_panel,
|
||||
takefocus=False,
|
||||
)
|
||||
self.pantone_baseline_btn.pack(fill=tk.X, padx=0, pady=1)
|
||||
|
||||
# Gamma 测试图案配置按钮
|
||||
self.gamma_pattern_btn = ttk.Button(
|
||||
self.sidebar_frame,
|
||||
text="Gamma 图案配置",
|
||||
style="Sidebar.TButton",
|
||||
command=self.toggle_gamma_pattern_panel,
|
||||
takefocus=False,
|
||||
)
|
||||
self.gamma_pattern_btn.pack(fill=tk.X, padx=0, pady=1)
|
||||
|
||||
# CALMAN 风格灰阶测试按钮
|
||||
self.calman_btn = ttk.Button(
|
||||
self.sidebar_frame,
|
||||
text="CALMAN 灰阶",
|
||||
style="Sidebar.TButton",
|
||||
command=self.toggle_calman_panel,
|
||||
takefocus=False,
|
||||
)
|
||||
self.calman_btn.pack(fill=tk.X, padx=0, pady=1)
|
||||
panel_buttons = [
|
||||
("log_btn", "测试日志", self.toggle_log_panel),
|
||||
("local_dimming_btn", "Local Dimming", self.toggle_local_dimming_panel),
|
||||
("ai_image_btn", "AI 图片", self.toggle_ai_image_panel),
|
||||
("pantone_baseline_btn", "Pantone 摸底", self.toggle_pantone_baseline_panel),
|
||||
("gamma_pattern_btn", "Gamma 图案", self.toggle_gamma_pattern_panel),
|
||||
("calman_btn", "CALMAN 灰阶", self.toggle_calman_panel),
|
||||
]
|
||||
for attr, text, cmd in panel_buttons:
|
||||
btn = ttk.Button(
|
||||
self.sidebar_frame,
|
||||
text=text,
|
||||
style="Sidebar.TButton",
|
||||
command=cmd,
|
||||
takefocus=False,
|
||||
)
|
||||
btn.pack(fill=tk.X, padx=0, pady=1)
|
||||
setattr(self, attr, btn)
|
||||
|
||||
# 测试版水印标签(版本 x.x.0.0 时显示)
|
||||
from app_version import is_beta_version, APP_VERSION
|
||||
@@ -701,6 +673,17 @@ def create_test_type_frame(self: "PQAutomationApp"):
|
||||
)
|
||||
beta_lbl.pack(fill=tk.X, side=tk.BOTTOM, padx=4, pady=(6, 4))
|
||||
|
||||
# ---------- 主题切换(底部固定) ----------
|
||||
self.theme_toggle_btn = ttk.Button(
|
||||
self.sidebar_frame,
|
||||
text="切换深色模式",
|
||||
style="Sidebar.TButton",
|
||||
command=self._on_toggle_theme,
|
||||
takefocus=False,
|
||||
)
|
||||
self.theme_toggle_btn.pack(fill=tk.X, padx=0, pady=(0, 2), side=tk.BOTTOM)
|
||||
_refresh_theme_toggle_label(self)
|
||||
|
||||
# 注册面板按钮
|
||||
if hasattr(self, "panels"):
|
||||
if "log" in self.panels:
|
||||
@@ -710,7 +693,7 @@ def create_test_type_frame(self: "PQAutomationApp"):
|
||||
if "ai_image" in self.panels:
|
||||
self.panels["ai_image"]["button"] = self.ai_image_btn
|
||||
if "single_step" in self.panels:
|
||||
self.panels["single_step"]["button"] = self.single_step_btn
|
||||
self.panels["single_step"]["button"] = getattr(self, "single_step_btn", None)
|
||||
if "pantone_baseline" in self.panels:
|
||||
self.panels["pantone_baseline"]["button"] = self.pantone_baseline_btn
|
||||
if "gamma_pattern" in self.panels:
|
||||
@@ -719,6 +702,30 @@ def create_test_type_frame(self: "PQAutomationApp"):
|
||||
self.panels["calman"]["button"] = self.calman_btn
|
||||
|
||||
|
||||
def _refresh_theme_toggle_label(self: "PQAutomationApp") -> None:
|
||||
"""根据当前主题刷新切换按钮的文字。"""
|
||||
from app.views.theme_manager import is_dark
|
||||
if not hasattr(self, "theme_toggle_btn"):
|
||||
return
|
||||
if is_dark():
|
||||
self.theme_toggle_btn.configure(text="切换浅色模式")
|
||||
else:
|
||||
self.theme_toggle_btn.configure(text="切换深色模式")
|
||||
|
||||
|
||||
def _on_toggle_theme(self: "PQAutomationApp") -> None:
|
||||
"""切换主题:重新应用 ttk 样式并刷新所有自定义样式相关的标签。"""
|
||||
from app.views.theme_manager import toggle_theme
|
||||
toggle_theme()
|
||||
_refresh_theme_toggle_label(self)
|
||||
# 同步刷新侧栏选中态(高亮样式跟随新色板)
|
||||
if hasattr(self, "update_sidebar_selection"):
|
||||
try:
|
||||
self.update_sidebar_selection()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def update_config_info_display(self: "PQAutomationApp"):
|
||||
"""更新配置信息显示"""
|
||||
if hasattr(self, "config") and hasattr(self.config, "get_current_config"):
|
||||
@@ -1046,6 +1053,7 @@ class MainLayoutMixin:
|
||||
create_test_type_frame = create_test_type_frame
|
||||
update_config_info_display = update_config_info_display
|
||||
create_operation_frame = create_operation_frame
|
||||
_on_toggle_theme = _on_toggle_theme
|
||||
on_screen_module_timing_changed = on_screen_module_timing_changed
|
||||
on_screen_module_signal_format_changed = on_screen_module_signal_format_changed
|
||||
on_sdr_timing_changed = on_sdr_timing_changed
|
||||
|
||||
Reference in New Issue
Block a user