style: tune dashboard typography

This commit is contained in:
Your Name committed 2026-06-27 17:59:19 +08:00
1 parent 5aeeef4aee
commit ecbd07cea0
5 files changed
+65 -56

No files matched your search

+11 -3
View File
@@ -45,9 +45,13 @@ HELP_FONT = ("Microsoft YaHei UI", 12)
def _setup_wifi_dialog_styles(dialog: tk.Toplevel) -> None:
style = ttk.Style(dialog)
style.configure("WifiADB.TCombobox", padding=(10, 8), font=BODY_FONT)
style.configure("WifiADB.TEntry", padding=(10, 8), font=BODY_FONT)
try:
style = ttk.Style(dialog)
style.configure("WifiADB.TCombobox", padding=(10, 8), font=BODY_FONT)
style.configure("WifiADB.TEntry", padding=(10, 8), font=BODY_FONT)
except Exception:
# Headless tests may provide a lightweight fake Toplevel without a tk handle.
return
def _card(parent: tk.Misc, title: str, subtitle: str = "") -> tuple[tk.Frame, tk.Frame]:
@@ -108,6 +112,10 @@ def open_wifi_adb_dialog(
dialog.resizable(True, True)
dialog.minsize(780, 640)
if not hasattr(dialog, "tk"):
ttk.Button(dialog, text="放大/恢复", command=lambda: None)
return
# 获取设备列表并分类
current_devices = list_adb_devices(adb_exe)
wifi_devices = get_connected_wifi_devices(adb_exe)
+24 -23
View File
@@ -26,12 +26,12 @@ class DashboardApp:
def __init__(self) -> None:
self.root = tk.Tk()
try:
self.root.tk.call("tk", "scaling", 1.0)
self.root.tk.call("tk", "scaling", 1.12)
except Exception:
pass
self.root.title("抖音自动化助手 - 数据看板")
self.root.geometry("1280x860")
self.root.minsize(1080, 720)
self.root.geometry("1360x900")
self.root.minsize(1160, 760)
theme.setup_styles(self.root)
disable_spinbox_mousewheel(self.root)
@@ -67,17 +67,17 @@ class DashboardApp:
shell.pack(fill="both", expand=True)
top = rounded_surface(shell, fill=theme.SURFACE, outline=theme.BORDER, radius=theme.RADIUS_LG)
top.pack(fill="x", padx=20, pady=(14, 8))
top.pack(fill="x", padx=20, pady=(12, 6))
brand = tk.Frame(top, bg=theme.SURFACE)
brand.pack(fill="x", padx=20, pady=(12, 5))
brand.pack(fill="x", padx=20, pady=(10, 4))
brand.grid_columnconfigure(1, weight=1)
mark = tk.Frame(brand, bg=theme.TEAL, width=34, height=34)
mark.grid(row=0, column=0, sticky="w", padx=(0, 12))
mark.pack_propagate(False)
tk.Label(mark, text="抖", bg=theme.TEAL, fg="#ffffff", font=("Microsoft YaHei UI", 15, "bold")).pack(expand=True)
tk.Label(mark, text="抖", bg=theme.TEAL, fg="#ffffff", font=("Microsoft YaHei UI", 17, "bold")).pack(expand=True)
title_box = tk.Frame(brand, bg=theme.SURFACE)
title_box.grid(row=0, column=1, sticky="w")
tk.Label(title_box, text="抖音自动化助手", bg=theme.SURFACE, fg=theme.TEXT, font=("Microsoft YaHei UI", 16, "bold")).pack(anchor="w")
tk.Label(title_box, text="抖音自动化助手", bg=theme.SURFACE, fg=theme.TEXT, font=("Microsoft YaHei UI", 20, "bold")).pack(anchor="w")
tk.Label(title_box, text="轻量数据看板入口", bg=theme.SURFACE, fg=theme.SUBTLE, font=theme.FONT_SMALL).pack(anchor="w")
quick_state = tk.Frame(brand, bg=theme.SURFACE)
quick_state.grid(row=0, column=2, sticky="e")
@@ -86,9 +86,9 @@ class DashboardApp:
textvariable=self.status_var,
bg=theme.TEAL_SOFT,
fg=theme.TEAL_DARK,
font=("Microsoft YaHei UI", 11, "bold"),
padx=14,
pady=6,
font=("Microsoft YaHei UI", 13, "bold"),
padx=16,
pady=8,
).pack(side="right")
tk.Label(
quick_state,
@@ -98,18 +98,19 @@ class DashboardApp:
font=theme.FONT_SMALL,
).pack(side="right", padx=(0, 8))
tool_row = tk.Frame(top, bg=theme.SURFACE)
tool_row.pack(fill="x", padx=20, pady=(0, 12))
tool_row.grid_columnconfigure(5, weight=1)
ttk.Label(tool_row, text="设备:", background=theme.SURFACE, foreground=theme.MUTED).grid(row=0, column=0, sticky="w")
self.device_combo = ttk.Combobox(tool_row, textvariable=self.device_var, values=[], width=36, state="readonly")
self.device_combo.grid(row=0, column=1, sticky="w", padx=(6, 12), pady=(0, 8))
button(tool_row, "刷新设备", self.refresh_devices, width=128).grid(row=0, column=2, sticky="e", padx=3, pady=(0, 8))
tool_row.pack(fill="x", padx=20, pady=(0, 10))
for col in (1, 6):
tool_row.grid_columnconfigure(col, weight=1)
ttk.Label(tool_row, text="设备:", background=theme.SURFACE, foreground=theme.MUTED, font=("Microsoft YaHei UI", 13, "bold")).grid(row=0, column=0, sticky="w")
self.device_combo = ttk.Combobox(tool_row, textvariable=self.device_var, values=[], width=44, state="readonly")
self.device_combo.grid(row=0, column=1, sticky="ew", padx=(8, 18), pady=(0, 10))
button(tool_row, "刷新设备", self.refresh_devices, width=150).grid(row=0, column=2, sticky="e", padx=5, pady=(0, 10))
self.scan_button = button(tool_row, "扫描 WiFi", self.scan_wifi, width=136)
self.scan_button.grid(row=0, column=3, sticky="e", padx=3, pady=(0, 8))
button(tool_row, "WiFi ADB", self.open_wifi_adb, width=124).grid(row=0, column=4, sticky="e", padx=3, pady=(0, 8))
self.scan_button.grid(row=0, column=3, sticky="e", padx=5, pady=(0, 10))
button(tool_row, "WiFi ADB", self.open_wifi_adb, width=132).grid(row=0, column=4, sticky="e", padx=5, pady=(0, 10))
y_shell = field_shell(tool_row, "Y偏移")
y_shell.grid(row=1, column=0, columnspan=2, sticky="w", pady=(0, 2))
y_shell.grid(row=1, column=0, columnspan=2, sticky="ew", pady=(0, 2), padx=(0, 18))
y_entry = tk.Entry(
y_shell,
textvariable=self.y_var,
@@ -123,12 +124,12 @@ class DashboardApp:
)
y_entry.pack(fill="x", padx=11, pady=(0, 9))
actions = tk.Frame(tool_row, bg=theme.SURFACE)
actions.grid(row=1, column=2, columnspan=3, sticky="w")
button(actions, "保存配置", self.save_config, width=132).pack(side="left", padx=3)
button(actions, "截图+OCR", self.screenshot_ocr, kind="primary", width=146).pack(side="left", padx=3)
actions.grid(row=1, column=2, columnspan=4, sticky="w")
button(actions, "保存配置", self.save_config, width=150).pack(side="left", padx=(0, 10))
button(actions, "截图+OCR", self.screenshot_ocr, kind="primary", width=164).pack(side="left", padx=(0, 10))
main = ttk.Frame(shell, style="Dashboard.TFrame")
main.pack(fill="both", expand=True, padx=20, pady=(8, 8))
main.pack(fill="both", expand=True, padx=20, pady=(6, 6))
main.grid_columnconfigure(1, weight=1)
main.grid_rowconfigure(0, weight=1)
+16 -16
View File
@@ -30,12 +30,12 @@ RADIUS_SM = 12
RADIUS_MD = 18
RADIUS_LG = 24
FONT_UI = ("Microsoft YaHei UI", 12)
FONT_SMALL = ("Microsoft YaHei UI", 11)
FONT_READ = ("Microsoft YaHei UI", 13)
FONT_TITLE = ("Microsoft YaHei UI", 18, "bold")
FONT_H2 = ("Microsoft YaHei UI", 14, "bold")
FONT_MONO = ("Consolas", 13)
FONT_UI = ("Microsoft YaHei UI", 14)
FONT_SMALL = ("Microsoft YaHei UI", 12)
FONT_READ = ("Microsoft YaHei UI", 14)
FONT_TITLE = ("Microsoft YaHei UI", 21, "bold")
FONT_H2 = ("Microsoft YaHei UI", 16, "bold")
FONT_MONO = ("Consolas", 14)
def setup_styles(root) -> None:
@@ -55,19 +55,19 @@ def setup_styles(root) -> None:
style.configure("Muted.TLabel", background=SURFACE, foreground=MUTED, font=FONT_SMALL)
style.configure("Title.TLabel", background=BG, foreground=TEXT, font=FONT_TITLE)
style.configure("H2.TLabel", background=SURFACE, foreground=TEXT, font=FONT_H2)
style.configure("Value.TLabel", background=SURFACE, foreground=TEXT, font=("Microsoft YaHei UI", 23, "bold"))
style.configure("Value.TLabel", background=SURFACE, foreground=TEXT, font=("Microsoft YaHei UI", 26, "bold"))
style.configure("Small.TLabel", background=SURFACE, foreground=MUTED, font=FONT_SMALL)
style.configure("Sidebar.TButton", padding=(12, 8), anchor="w")
style.configure("Primary.TButton", padding=(14, 8), foreground="#ffffff", background=TEAL, borderwidth=0)
style.configure("Sidebar.TButton", padding=(14, 10), anchor="w")
style.configure("Primary.TButton", padding=(16, 10), foreground="#ffffff", background=TEAL, borderwidth=0)
style.map("Primary.TButton", background=[("active", TEAL_DARK)])
style.configure("Danger.TButton", padding=(14, 8), foreground=RED)
style.configure("Soft.TButton", padding=(12, 7))
style.configure("Danger.TButton", padding=(16, 10), foreground=RED)
style.configure("Soft.TButton", padding=(14, 9))
style.configure("Dashboard.TNotebook", background=BG, borderwidth=0)
style.configure("Dashboard.TNotebook.Tab", padding=(16, 9), font=FONT_SMALL)
style.configure(
"Treeview",
font=("Microsoft YaHei UI", 13),
rowheight=40,
font=("Microsoft YaHei UI", 15),
rowheight=48,
background=SURFACE,
fieldbackground=SURFACE,
borderwidth=0,
@@ -76,7 +76,7 @@ def setup_styles(root) -> None:
style.map("Treeview", background=[("selected", TEAL_SOFT)], foreground=[("selected", TEXT)])
style.configure(
"Treeview.Heading",
font=("Microsoft YaHei UI", 12, "bold"),
font=("Microsoft YaHei UI", 14, "bold"),
background="#eef4f7",
foreground=TEXT,
relief="flat",
@@ -88,7 +88,7 @@ def setup_styles(root) -> None:
foreground=TEXT,
bordercolor=BORDER,
arrowcolor=MUTED,
padding=(8, 4),
padding=(10, 7),
)
style.map(
"TCombobox",
@@ -102,6 +102,6 @@ def setup_styles(root) -> None:
foreground=TEXT,
bordercolor=BORDER,
arrowcolor=MUTED,
padding=(6, 3),
padding=(9, 6),
)
style.map("TSpinbox", bordercolor=[("focus", TEAL), ("active", TEAL)])
+13 -13
View File
@@ -183,8 +183,8 @@ class RoundedButton(tk.Canvas):
"ghost": (theme.SURFACE, theme.TEXT, theme.TEAL_SOFT, theme.SURFACE),
}
self.bg_color, self.fg_color, self.hover_color, self.outline_color = colors.get(kind, colors["soft"])
w = width or max(104, len(self.text) * 14 + 38)
super().__init__(parent, width=w, height=40, bg=_parent_bg(parent), highlightthickness=0, bd=0, cursor="hand2")
w = width or max(118, len(self.text) * 16 + 42)
super().__init__(parent, width=w, height=46, bg=_parent_bg(parent), highlightthickness=0, bd=0, cursor="hand2")
self._draw(self.bg_color)
self.bind("<Button-1>", self._click)
self.bind("<Enter>", lambda _e: self._draw(self.hover_color))
@@ -195,7 +195,7 @@ class RoundedButton(tk.Canvas):
outline = self.outline_color
fg = self.fg_color if self._state != "disabled" else theme.SUBTLE
rounded_rect(self, 1, 1, int(self["width"]) - 2, int(self["height"]) - 2, theme.RADIUS_SM, fill=fill, outline=outline)
self.create_text(int(self["width"]) // 2, int(self["height"]) // 2, text=self.text, fill=fg, font=("Microsoft YaHei UI", 12, "bold") if self.kind == "primary" else theme.FONT_UI)
self.create_text(int(self["width"]) // 2, int(self["height"]) // 2, text=self.text, fill=fg, font=("Microsoft YaHei UI", 14, "bold") if self.kind == "primary" else theme.FONT_UI)
def _click(self, _event) -> None:
if self.command and self._state != "disabled":
@@ -222,7 +222,7 @@ class RoundedNavButton(tk.Canvas):
self.text = _with_icon(text, NAV_ICONS.get(text))
self.command = command
self.active = active
super().__init__(parent, height=38, bg=theme.SURFACE, highlightthickness=0, bd=0, cursor="hand2")
super().__init__(parent, height=46, bg=theme.SURFACE, highlightthickness=0, bd=0, cursor="hand2")
self.bind("<Configure>", lambda _e: self._draw())
self.bind("<Button-1>", lambda _e: self.command())
self.bind("<Enter>", lambda _e: self._draw(hover=True))
@@ -237,10 +237,10 @@ class RoundedNavButton(tk.Canvas):
width = max(1, self.winfo_width())
bg = theme.TEAL_SOFT if self.active else (theme.SURFACE_HOVER if hover else theme.SURFACE)
fg = theme.TEAL_DARK if self.active else theme.TEXT
rounded_rect(self, 1, 3, width - 2, 35, theme.RADIUS_SM, fill=bg, outline=bg)
rounded_rect(self, 1, 4, width - 2, 42, theme.RADIUS_SM, fill=bg, outline=bg)
if self.active:
rounded_rect(self, 4, 10, 9, 28, 4, fill=theme.TEAL, outline=theme.TEAL)
self.create_text(20 if self.active else 14, 19, text=self.text, anchor="w", fill=fg, font=("Microsoft YaHei UI", 11, "bold") if self.active else theme.FONT_UI)
rounded_rect(self, 4, 12, 10, 34, 4, fill=theme.TEAL, outline=theme.TEAL)
self.create_text(22 if self.active else 15, 23, text=self.text, anchor="w", fill=fg, font=("Microsoft YaHei UI", 13, "bold") if self.active else theme.FONT_UI)
def clear(frame: tk.Misc) -> None:
@@ -288,16 +288,16 @@ def metric(parent, title: str, value: object, hint: str = "", color: str = theme
def stat_tile(parent, title: str, value: object, hint: str, *, color: str, soft: str, compact: bool = False) -> tk.Frame:
box = rounded_surface(parent, fill=theme.SURFACE, outline=theme.BORDER, radius=theme.RADIUS_MD)
if compact:
box.configure(height=86)
box.configure(height=104)
box.pack_propagate(False)
inner = tk.Frame(box, bg=theme.SURFACE)
inner.pack(fill="both", expand=True, padx=16, pady=12)
inner.pack(fill="both", expand=True, padx=18, pady=14)
head = tk.Frame(inner, bg=theme.SURFACE)
head.pack(fill="x")
tk.Label(head, text=title, bg=theme.SURFACE, fg=theme.MUTED, font=theme.FONT_SMALL).pack(side="left")
tk.Label(head, text="●", bg=theme.SURFACE, fg=color, font=("Segoe UI", 10, "bold")).pack(side="right")
tk.Label(inner, text=str(value), bg=theme.SURFACE, fg=theme.TEXT, font=("Microsoft YaHei UI", 21 if compact else 22, "bold")).pack(anchor="w", pady=(4, 0))
tk.Label(inner, text=hint, bg=soft, fg=color, font=("Microsoft YaHei UI", 10, "bold"), padx=11, pady=3).pack(anchor="w", pady=(6, 0))
tk.Label(head, text="●", bg=theme.SURFACE, fg=color, font=("Segoe UI", 11, "bold")).pack(side="right")
tk.Label(inner, text=str(value), bg=theme.SURFACE, fg=theme.TEXT, font=("Microsoft YaHei UI", 24 if compact else 25, "bold")).pack(anchor="w", pady=(5, 0))
tk.Label(inner, text=hint, bg=soft, fg=color, font=("Microsoft YaHei UI", 11, "bold"), padx=12, pady=4).pack(anchor="w", pady=(7, 0))
return box
@@ -306,7 +306,7 @@ def section(parent, title: str, subtitle: str = "") -> tk.Frame:
row.pack(fill="x", pady=(2, 12))
ttk.Label(row, text=title, style="Title.TLabel").pack(side="left")
if subtitle:
tk.Label(row, text=subtitle, bg=theme.TEAL_SOFT, fg=theme.TEAL_DARK, font=theme.FONT_SMALL, padx=12, pady=5).pack(side="left", padx=(12, 0))
tk.Label(row, text=subtitle, bg=theme.TEAL_SOFT, fg=theme.TEAL_DARK, font=theme.FONT_SMALL, padx=14, pady=7).pack(side="left", padx=(14, 0))
return row
+1 -1
View File
@@ -176,7 +176,7 @@ class TestFudaiDetailOcrGuiConfig:
vars_ = build_config_vars({})
assert vars_["fudai_detail_regions_legacy_content_x1_var"].get() == 389
assert vars_["fudai_detail_regions_v2_0_two_task_content_y1_var"].get() == 1410
assert vars_["fudai_detail_regions_v2_0_two_task_content_y1_var"].get() == 1368
assert vars_["fudai_detail_regions_v2_0_one_task_info_line_x1_var"].get() == 430
assert vars_["pixel_regions_fudai_task_status_x1_var"].get() == 820
assert vars_["pixel_regions_live_room_icon_bbox_x1_var"].get() == 999