103 lines
3.5 KiB
Python
103 lines
3.5 KiB
Python
"""Небольшой экран загрузки, пока строится основное окно."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import tkinter as tk
|
|
|
|
from .core import prefs
|
|
from .components.icons import render_icon
|
|
from .version import __version__
|
|
|
|
_DARK = {
|
|
"bg": "#161513",
|
|
"panel": "#1c1a18",
|
|
"border": "#2d2925",
|
|
"text": "#efe9de",
|
|
"dim": "#aaa398",
|
|
"faint": "#8a847a",
|
|
"accent": "#d08a4b",
|
|
}
|
|
_LIGHT = {
|
|
"bg": "#f7f4ee",
|
|
"panel": "#fdfbf7",
|
|
"border": "#e5ded2",
|
|
"text": "#1f1b16",
|
|
"dim": "#5e554a",
|
|
"faint": "#6f665a",
|
|
"accent": "#a45f26",
|
|
}
|
|
|
|
|
|
def _palette() -> dict:
|
|
try:
|
|
theme = str(prefs.load().get("theme") or "dark")
|
|
except Exception:
|
|
theme = "dark"
|
|
return _LIGHT if theme == "light" else _DARK
|
|
|
|
|
|
class SplashScreen(tk.Toplevel):
|
|
"""Splash-окно как Toplevel, чтобы не создавать второй Tk-корень."""
|
|
|
|
def __init__(self, master):
|
|
super().__init__(master)
|
|
p = _palette()
|
|
self.title("Xenith Studio")
|
|
self.configure(bg=p["bg"])
|
|
try:
|
|
self.overrideredirect(True)
|
|
self.attributes("-topmost", True)
|
|
except Exception:
|
|
pass
|
|
|
|
width, height = 424, 196
|
|
try:
|
|
screen_w = master.winfo_screenwidth()
|
|
screen_h = master.winfo_screenheight()
|
|
x = max(0, (screen_w - width) // 2)
|
|
y = max(0, (screen_h - height) // 2)
|
|
self.geometry(f"{width}x{height}+{x}+{y}")
|
|
except Exception:
|
|
self.geometry(f"{width}x{height}")
|
|
|
|
frame = tk.Frame(self, bg=p["panel"], highlightthickness=1,
|
|
highlightbackground=p["border"])
|
|
frame.pack(fill="both", expand=True, padx=1, pady=1)
|
|
|
|
head = tk.Frame(frame, bg=p["panel"])
|
|
head.pack(fill="x", padx=28, pady=(30, 0))
|
|
|
|
mark = tk.Canvas(head, width=30, height=34, bg=p["panel"],
|
|
highlightthickness=0, bd=0)
|
|
mark.pack(side="left", padx=(0, 12))
|
|
# Тот же след, что в логотипе сайдбара: один янтарный штрих.
|
|
photo = render_icon("trace", 30, p["accent"])
|
|
if photo is not None:
|
|
mark._photo = photo
|
|
mark.create_image(15, 17, image=photo, anchor="center")
|
|
else:
|
|
mark.create_line(5, 27, 13, 15, 19, 21, 26, 8, fill=p["accent"],
|
|
width=2, capstyle="round", joinstyle="round")
|
|
|
|
title_box = tk.Frame(head, bg=p["panel"])
|
|
title_box.pack(side="left")
|
|
tk.Label(title_box, text="Xenith", bg=p["panel"], fg=p["text"],
|
|
font=("Adwaita Sans", 24), anchor="w").pack(anchor="w")
|
|
tk.Label(title_box, text="Studio", bg=p["panel"], fg=p["faint"],
|
|
font=("Adwaita Sans", 11), anchor="w").pack(anchor="w")
|
|
|
|
tk.Label(frame, text="Подготовка интерфейса и моделей",
|
|
bg=p["panel"], fg=p["dim"], anchor="w",
|
|
font=("Adwaita Sans", 11)).pack(anchor="w", padx=28, pady=(24, 0))
|
|
|
|
bottom = tk.Frame(frame, bg=p["panel"])
|
|
bottom.pack(side="bottom", fill="x", padx=28, pady=(0, 22))
|
|
tk.Label(bottom, text=f"Версия {__version__}", bg=p["panel"],
|
|
fg=p["faint"], font=("Adwaita Sans", 10)).pack(side="left")
|
|
|
|
try:
|
|
self.update_idletasks()
|
|
self.update()
|
|
except Exception:
|
|
pass
|