AnimeVideoEditot/gui/theme.py
2026-03-14 19:52:44 +03:00

143 lines
3.9 KiB
Python

# -*- coding: utf-8 -*-
"""Стили и тема приложения — тёмная тема в стиле Catppuccin Mocha."""
import tkinter as tk
from tkinter import ttk
# Палитра Catppuccin Mocha
COLORS = {
"bg": "#1e1e2e", # Base
"surface": "#313244", # Surface0
"overlay": "#45475a", # Surface1
"text": "#cdd6f4", # Text
"subtext": "#a6adc8", # Subtext0
"accent": "#89b4fa", # Blue
"accent_hover": "#b4befe", # Lavender
"green": "#a6e3a1", # Green
"red": "#f38ba8", # Red
"yellow": "#f9e2af", # Yellow
"border": "#585b70", # Surface2
}
def setup_theme(root: tk.Tk):
"""Применяет тёмную тему к окну и настраивает ttk.Style."""
root.configure(bg=COLORS["bg"])
root.option_add("*Font", "Tahoma 10")
style = ttk.Style(root)
style.theme_use("clam")
# Общие
style.configure(
".",
background=COLORS["bg"],
foreground=COLORS["text"],
fieldbackground=COLORS["surface"],
troughcolor=COLORS["overlay"],
borderwidth=0,
)
style.map(".", background=[("active", COLORS["overlay"])])
# Frame / карточки
style.configure(
"Card.TFrame",
background=COLORS["surface"],
relief="flat",
)
style.configure(
"Card.TLabelframe",
background=COLORS["surface"],
foreground=COLORS["text"],
)
style.configure(
"Card.TLabelframe.Label",
background=COLORS["surface"],
foreground=COLORS["accent"],
font="Tahoma 10 bold",
)
# Кнопки
style.configure(
"TButton",
background=COLORS["overlay"],
foreground=COLORS["text"],
padding=(12, 6),
font="Tahoma 9",
)
style.map(
"TButton",
background=[("active", COLORS["border"]), ("pressed", COLORS["accent"])],
foreground=[("active", COLORS["text"])],
)
# Акцентная кнопка (Выполнить)
style.configure(
"Accent.TButton",
background=COLORS["accent"],
foreground=COLORS["bg"],
padding=(20, 10),
font="Tahoma 10 bold",
)
style.map(
"Accent.TButton",
background=[("active", COLORS["accent_hover"]), ("pressed", COLORS["overlay"])],
foreground=[("active", COLORS["bg"])],
)
# Поля ввода
style.configure(
"TEntry",
fieldbackground=COLORS["surface"],
foreground=COLORS["text"],
insertcolor=COLORS["text"],
padding=6,
)
# Combobox
style.configure(
"TCombobox",
fieldbackground=COLORS["surface"],
background=COLORS["overlay"],
foreground=COLORS["text"],
arrowcolor=COLORS["text"],
padding=6,
)
style.map("TCombobox", fieldbackground=[("readonly", COLORS["surface"])])
# Progressbar
style.configure(
"TProgressbar",
background=COLORS["accent"],
troughcolor=COLORS["overlay"],
borderwidth=0,
thickness=8,
)
# Scrollbar
style.configure(
"TScrollbar",
background=COLORS["overlay"],
troughcolor=COLORS["surface"],
borderwidth=0,
arrowcolor=COLORS["text"],
)
style.map("TScrollbar", background=[("active", COLORS["border"])])
# Label — шрифт одной строкой, иначе Tcl воспринимает "UI" как размер
style.configure("TLabel", background=COLORS["bg"], foreground=COLORS["text"])
style.configure(
"Header.TLabel",
background=COLORS["bg"],
foreground=COLORS["text"],
font="Tahoma 16 bold",
)
style.configure(
"Subtext.TLabel",
background=COLORS["surface"],
foreground=COLORS["subtext"],
font="Tahoma 9",
)
return style