diff --git a/gui/dashboard_app/app.py b/gui/dashboard_app/app.py index 6f298d7..8267d66 100644 --- a/gui/dashboard_app/app.py +++ b/gui/dashboard_app/app.py @@ -65,19 +65,19 @@ class DashboardApp: shell.pack(fill="both", expand=True) top = tk.Frame(shell, bg=theme.SURFACE, highlightbackground=theme.BORDER, highlightthickness=1) - top.pack(fill="x", padx=16, pady=(12, 7)) + top.pack(fill="x", padx=18, pady=(14, 8)) brand = tk.Frame(top, bg=theme.SURFACE) - brand.pack(fill="x", padx=14, pady=(8, 3)) - mark = tk.Frame(brand, bg=theme.TEAL, width=28, height=28) - mark.pack(side="left", padx=(0, 9)) + brand.pack(fill="x", padx=18, pady=(12, 5)) + mark = tk.Frame(brand, bg=theme.TEAL, width=34, height=34) + mark.pack(side="left", padx=(0, 12)) mark.pack_propagate(False) - tk.Label(mark, text="抖", bg=theme.TEAL, fg="#ffffff", font=("Microsoft YaHei UI", 13, "bold")).pack(expand=True) + tk.Label(mark, text="抖", bg=theme.TEAL, fg="#ffffff", font=("Microsoft YaHei UI", 15, "bold")).pack(expand=True) title_box = tk.Frame(brand, bg=theme.SURFACE) title_box.pack(side="left") - 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", 17, "bold")).pack(anchor="w") tk.Label(title_box, text="轻量数据看板入口", bg=theme.SURFACE, fg=theme.SUBTLE, font=theme.FONT_SMALL).pack(anchor="w") tool_row = tk.Frame(top, bg=theme.SURFACE) - tool_row.pack(fill="x", padx=14, pady=(0, 8)) + tool_row.pack(fill="x", padx=18, pady=(0, 12)) ttk.Label(tool_row, text="设备:", background=theme.SURFACE, foreground=theme.MUTED).pack(side="left") self.device_combo = ttk.Combobox(tool_row, textvariable=self.device_var, values=[], width=28) self.device_combo.pack(side="left", padx=(4, 8)) @@ -91,13 +91,13 @@ class DashboardApp: button(tool_row, "截图+OCR", self.screenshot_ocr, kind="primary", width=132).pack(side="right", padx=3) main = ttk.Frame(shell, style="Dashboard.TFrame") - main.pack(fill="both", expand=True, padx=16, pady=(4, 7)) + main.pack(fill="both", expand=True, padx=18, pady=(6, 8)) main.grid_columnconfigure(1, weight=1) main.grid_rowconfigure(0, weight=1) sidebar = tk.Frame(main, bg=theme.SURFACE, highlightbackground=theme.BORDER, highlightthickness=1) - sidebar.grid(row=0, column=0, sticky="nsw", padx=(0, 14)) - sidebar.configure(width=188) + sidebar.grid(row=0, column=0, sticky="nsw", padx=(0, 16)) + sidebar.configure(width=204) sidebar.grid_propagate(False) sidebar.pack_propagate(False) for group_title, names in [ @@ -106,10 +106,10 @@ class DashboardApp: ("数据", ["运行日志", "截图预览", "统计信息", "预约队列", "高价值房间", "行为日志", "实时状态", "OCR结果", "中奖记录", "映射表"]), ("连接", ["WiFi ADB"]), ]: - ttk.Label(sidebar, text=group_title, background=theme.SURFACE, foreground=theme.MUTED, font=theme.FONT_SMALL).pack(anchor="w", padx=12, pady=(10, 3)) + ttk.Label(sidebar, text=group_title, background=theme.SURFACE, foreground=theme.MUTED, font=theme.FONT_SMALL).pack(anchor="w", padx=14, pady=(13, 5)) for name in names: btn = nav_button(sidebar, name, lambda n=name: self.show_page(n), active=name == self.current_page) - btn.pack(fill="x", padx=8, pady=0) + btn.pack(fill="x", padx=10, pady=1) self.nav_buttons[name] = btn self.content_scroll = ScrollFrame(main) @@ -117,9 +117,9 @@ class DashboardApp: self.content = self.content_scroll.inner bottom = tk.Frame(shell, bg=theme.SURFACE, highlightbackground=theme.BORDER, highlightthickness=1) - bottom.pack(fill="x", padx=16, pady=(3, 12)) + bottom.pack(fill="x", padx=18, pady=(4, 14)) inner_bottom = tk.Frame(bottom, bg=theme.SURFACE) - inner_bottom.pack(fill="x", padx=12, pady=9) + inner_bottom.pack(fill="x", padx=14, pady=11) button(inner_bottom, "开始运行", self.start_run, kind="primary", width=132).pack(side="left", padx=(0, 8)) button(inner_bottom, "停止", self.stop_run, width=96).pack(side="left", padx=4) button(inner_bottom, "强制停止", self.force_stop_run, kind="danger", width=132).pack(side="left", padx=4) diff --git a/gui/dashboard_app/page_home.py b/gui/dashboard_app/page_home.py index 407931d..01377ba 100644 --- a/gui/dashboard_app/page_home.py +++ b/gui/dashboard_app/page_home.py @@ -83,13 +83,13 @@ def build_home(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None: body = tk.Frame(parent, bg=theme.BG) body.pack(fill="both", expand=True) - body.grid_columnconfigure(0, weight=3, minsize=520) - body.grid_columnconfigure(1, weight=2, minsize=360) + body.grid_columnconfigure(0, weight=3, minsize=540) + body.grid_columnconfigure(1, weight=2, minsize=380) left = tk.Frame(body, bg=theme.BG) right = tk.Frame(body, bg=theme.BG) - left.grid(row=0, column=0, sticky="nsew", padx=(0, 8)) - right.grid(row=0, column=1, sticky="nsew", padx=(8, 0)) + left.grid(row=0, column=0, sticky="nsew", padx=(0, 10)) + right.grid(row=0, column=1, sticky="nsew", padx=(10, 0)) rows = reservation_rows(data) for row in rows: diff --git a/gui/dashboard_app/theme.py b/gui/dashboard_app/theme.py index 011046b..5a0b575 100644 --- a/gui/dashboard_app/theme.py +++ b/gui/dashboard_app/theme.py @@ -3,28 +3,28 @@ from __future__ import annotations from tkinter import ttk -BG = "#f5f6f2" -BG_ALT = "#edf1eb" -SURFACE = "#fffefd" -SURFACE_ALT = "#f8faf7" -SURFACE_HOVER = "#f1f6f2" -BORDER = "#dde5dd" -BORDER_DARK = "#c8d4cb" -TEXT = "#111f1c" -MUTED = "#61716d" -SUBTLE = "#96a39f" -TEAL = "#078a7c" -TEAL_DARK = "#066d62" -TEAL_SOFT = "#e2f3ef" -AMBER = "#a86d00" -AMBER_SOFT = "#fff2d7" -RED = "#ca4747" -RED_SOFT = "#fff0ee" -GREEN = "#16834b" -GREEN_SOFT = "#e6f4eb" -BLUE = "#336fd0" -BLUE_SOFT = "#edf4ff" -SHADOW = "#e8ede8" +BG = "#f3f6f8" +BG_ALT = "#e8eef2" +SURFACE = "#ffffff" +SURFACE_ALT = "#f7fafc" +SURFACE_HOVER = "#edf7f5" +BORDER = "#d9e3e8" +BORDER_DARK = "#b9c8d0" +TEXT = "#10201f" +MUTED = "#5d6f78" +SUBTLE = "#94a4ad" +TEAL = "#0f9488" +TEAL_DARK = "#087368" +TEAL_SOFT = "#e6f7f3" +AMBER = "#a76707" +AMBER_SOFT = "#fff4dd" +RED = "#c74454" +RED_SOFT = "#fff0f2" +GREEN = "#15805a" +GREEN_SOFT = "#e5f5ee" +BLUE = "#2e6fd8" +BLUE_SOFT = "#eaf2ff" +SHADOW = "#e7edf1" RADIUS_SM = 8 RADIUS_MD = 12 @@ -77,7 +77,7 @@ def setup_styles(root) -> None: style.configure( "Treeview.Heading", font=("Microsoft YaHei UI", 12, "bold"), - background="#eef2eb", + background="#edf3f1", foreground=TEXT, relief="flat", ) @@ -90,6 +90,11 @@ def setup_styles(root) -> None: arrowcolor=MUTED, padding=(8, 4), ) + style.map( + "TCombobox", + fieldbackground=[("readonly", SURFACE_ALT)], + bordercolor=[("focus", TEAL), ("active", TEAL)], + ) style.configure( "TSpinbox", fieldbackground=SURFACE_ALT, @@ -99,3 +104,4 @@ def setup_styles(root) -> None: arrowcolor=MUTED, padding=(6, 3), ) + style.map("TSpinbox", bordercolor=[("focus", TEAL), ("active", TEAL)]) diff --git a/gui/dashboard_app/widgets.py b/gui/dashboard_app/widgets.py index 127d4e5..9eee796 100644 --- a/gui/dashboard_app/widgets.py +++ b/gui/dashboard_app/widgets.py @@ -123,7 +123,7 @@ class RoundedButton(tk.Canvas): "primary": (theme.TEAL, "#ffffff", theme.TEAL_DARK), "danger": (theme.RED_SOFT, theme.RED, "#ffe5e2"), "amber": (theme.AMBER_SOFT, "#8a5a00", "#ffe8b8"), - "soft": (theme.SURFACE_ALT, theme.TEXT, theme.SURFACE_HOVER), + "soft": (theme.SURFACE, theme.TEXT, theme.SURFACE_HOVER), "ghost": (theme.SURFACE, theme.TEXT, theme.TEAL_SOFT), } self.bg_color, self.fg_color, self.hover_color = colors.get(kind, colors["soft"]) @@ -136,7 +136,7 @@ class RoundedButton(tk.Canvas): def _draw(self, fill: str) -> None: self.delete("all") - outline = theme.BORDER_DARK if self.kind == "primary" else theme.BORDER + outline = theme.TEAL if self.kind == "primary" else theme.BORDER 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) @@ -212,8 +212,8 @@ def card(parent, title: str | None = None, *, padding: int = 14) -> tk.Frame: frame = tk.Frame(parent, bg=theme.SURFACE, highlightbackground=theme.BORDER, highlightthickness=1) if title: head = tk.Frame(frame, bg=theme.SURFACE) - head.pack(fill="x", padx=padding, pady=(padding - 2, 5)) - tk.Frame(head, bg=theme.TEAL, width=3, height=15).pack(side="left", padx=(0, 8)) + head.pack(fill="x", padx=padding + 2, pady=(padding, 7)) + tk.Frame(head, bg=theme.TEAL, width=4, height=18).pack(side="left", padx=(0, 10)) ttk.Label(head, text=title, style="H2.TLabel").pack(side="left") return frame @@ -233,31 +233,31 @@ def stat_tile(parent, title: str, value: object, hint: str, *, color: str, soft: box = tk.Frame(parent, bg=theme.SURFACE, highlightbackground=theme.BORDER, highlightthickness=1) if compact: box.configure(height=72) - accent = tk.Frame(box, bg=color, width=3) + accent = tk.Frame(box, bg=color, width=4) accent.pack(side="left", fill="y") inner = tk.Frame(box, bg=theme.SURFACE) inner.pack(side="left", fill="both", expand=True) head = tk.Frame(inner, bg=theme.SURFACE) - head.pack(fill="x", padx=13, pady=(8, 2)) + head.pack(fill="x", padx=16, pady=(10, 2)) 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", 18, "bold")).pack(anchor="w", padx=13) - tk.Label(inner, text=hint, bg=soft, fg=color, font=("Microsoft YaHei UI", 10, "bold"), padx=10, pady=2).pack(anchor="w", padx=13, pady=(5, 9)) + tk.Label(inner, text=str(value), bg=theme.SURFACE, fg=theme.TEXT, font=("Microsoft YaHei UI", 19, "bold")).pack(anchor="w", padx=16) + tk.Label(inner, text=hint, bg=soft, fg=color, font=("Microsoft YaHei UI", 10, "bold"), padx=11, pady=3).pack(anchor="w", padx=16, pady=(6, 10)) return box def section(parent, title: str, subtitle: str = "") -> tk.Frame: row = tk.Frame(parent, bg=theme.BG) - row.pack(fill="x", pady=(0, 8)) + row.pack(fill="x", pady=(2, 10)) 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=9, pady=2).pack(side="left", padx=(10, 0)) + tk.Label(row, text=subtitle, bg=theme.TEAL_SOFT, fg=theme.TEAL_DARK, font=theme.FONT_SMALL, padx=12, pady=4).pack(side="left", padx=(12, 0)) return row def flow_grid(parent, columns: int = 4) -> tk.Frame: grid = tk.Frame(parent, bg=theme.BG) - grid.pack(fill="x", pady=(0, 10)) + grid.pack(fill="x", pady=(0, 14)) for idx in range(columns): grid.grid_columnconfigure(idx, weight=1, uniform="metric") return grid @@ -296,7 +296,7 @@ def table_panel(parent, title: str, columns: Sequence[tuple[str, str, int]], row tree.insert("", "end", values=[str(row.get(key, "-")) for key, _, _ in columns]) if not rows: tree.insert("", "end", values=["暂无数据" if idx == 0 else "" for idx, _c in enumerate(columns)]) - tree.pack(fill="both", expand=True, padx=11, pady=(4, 11)) + tree.pack(fill="both", expand=True, padx=14, pady=(4, 14)) return box @@ -371,7 +371,7 @@ def toolbar(parent, actions: Sequence[tuple[str, Callable[[], None] | None, str] def preview_panel(parent, image_path: Path | None, title: str = "截图预览", max_size: tuple[int, int] = (360, 560)) -> tk.Frame: box = card(parent, title) body = tk.Frame(box, bg=theme.SURFACE_ALT, highlightbackground=theme.BORDER, highlightthickness=1) - body.pack(fill="both", expand=True, padx=11, pady=(4, 11)) + body.pack(fill="both", expand=True, padx=14, pady=(4, 14)) if image_path and image_path.exists(): try: from PIL import Image, ImageTk @@ -381,7 +381,7 @@ def preview_panel(parent, image_path: Path | None, title: str = "截图预览", photo = ImageTk.PhotoImage(img) label = tk.Label(body, image=photo, bg=theme.SURFACE_ALT) label.image = photo - label.pack(expand=True, pady=10) + label.pack(expand=True, pady=12) ttk.Label(body, text=os.path.basename(str(image_path)), background=theme.SURFACE_ALT, foreground=theme.MUTED).pack(pady=(0, 8)) return box except Exception: