Polish dashboard app visual style

This commit is contained in:
Your Name committed 2026-06-19 01:38:15 +08:00
1 parent 240f49825f
commit b850afae2c
4 files changed
+61 -55

No files matched your search

+14 -14
View File
@@ -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: