Files
douyi_guaji_main/gui/dashboard_app/theme.py
T

54 lines
2.1 KiB
Python

from __future__ import annotations
from tkinter import ttk
BG = "#f6f7f4"
SURFACE = "#ffffff"
SURFACE_ALT = "#f1f5f2"
BORDER = "#dfe7e2"
TEXT = "#1f2a2a"
MUTED = "#6d7a7a"
TEAL = "#009688"
TEAL_DARK = "#00796b"
AMBER = "#f59e0b"
RED = "#ef4444"
GREEN = "#16a34a"
BLUE = "#3b82f6"
FONT_UI = ("Microsoft YaHei UI", 10)
FONT_SMALL = ("Microsoft YaHei UI", 9)
FONT_TITLE = ("Microsoft YaHei UI", 15, "bold")
FONT_H2 = ("Microsoft YaHei UI", 12, "bold")
FONT_MONO = ("Consolas", 10)
def setup_styles(root) -> None:
root.configure(bg=BG)
style = ttk.Style(root)
try:
style.theme_use("clam")
except Exception:
pass
style.configure(".", font=FONT_UI)
style.configure("Dashboard.TFrame", background=BG)
style.configure("Surface.TFrame", background=SURFACE)
style.configure("Alt.TFrame", background=SURFACE_ALT)
style.configure("Card.TFrame", background=SURFACE, borderwidth=1, relief="solid")
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", 18, "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)
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("Dashboard.TNotebook", background=BG, borderwidth=0)
style.configure("Dashboard.TNotebook.Tab", padding=(14, 8), font=FONT_SMALL)
style.configure("Treeview", font=FONT_SMALL, rowheight=28, background=SURFACE, fieldbackground=SURFACE)
style.configure("Treeview.Heading", font=("Microsoft YaHei UI", 9, "bold"))