-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeme_dark.py
More file actions
95 lines (80 loc) · 2.66 KB
/
Copy paththeme_dark.py
File metadata and controls
95 lines (80 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# theme_dark.py
# Theme helpers for the "Dark Mode Pro" UI
import tkinter as tk
# Palette
BG = "#1e1e1e"
PANEL = "#252525"
CARD = "#2a2a2a"
ACCENT = "#0d7377"
ACCENT_HOVER = "#14a098"
TEXT = "#eeeeee"
MUTED = "#bdbdbd"
ERROR = "#e74c3c"
FONT = ("Segoe UI", 10)
FONT_BOLD = ("Segoe UI", 11, "bold")
FONT_BIG = ("Segoe UI", 12, "bold")
def style_root(root):
root.configure(bg=BG)
try:
root.option_add("*Font", FONT)
except:
pass
# Styled button (flat) with hover
class AccentButton(tk.Button):
def __init__(self, master, text="", command=None, width=None, **kwargs):
super().__init__(master,
text=text,
command=command,
bg=ACCENT,
fg=TEXT,
activebackground=ACCENT_HOVER,
bd=0,
relief="flat",
highlightthickness=0,
**kwargs)
if width:
self.configure(width=width)
self.bind("<Enter>", self._on_enter)
self.bind("<Leave>", self._on_leave)
def _on_enter(self, e):
self.configure(bg=ACCENT_HOVER)
def _on_leave(self, e):
self.configure(bg=ACCENT)
# Ghost button (outline)
class GhostButton(tk.Button):
def __init__(self, master, text="", command=None, **kwargs):
super().__init__(master,
text=text,
command=command,
bg=PANEL,
fg=TEXT,
bd=1,
relief="flat",
highlightthickness=0,
**kwargs)
self.bind("<Enter>", self._on_enter)
self.bind("<Leave>", self._on_leave)
def _on_enter(self, e):
self.configure(bg="#303030")
def _on_leave(self, e):
self.configure(bg=PANEL)
# Card frame (for results)
class Card(tk.Frame):
def __init__(self, master, width=600, height=100, **kwargs):
super().__init__(master, bg=CARD, bd=0, highlightthickness=0, **kwargs)
self.default_bg = CARD
self.hover_bg = "#313131"
self.configure(padx=8, pady=8)
self.bind("<Enter>", self._on_enter)
self.bind("<Leave>", self._on_leave)
def _on_enter(self, e):
self.configure(bg=self.hover_bg)
def _on_leave(self, e):
self.configure(bg=self.default_bg)
# Small label helpers
def Title(master, text):
lbl = tk.Label(master, text=text, bg=BG, fg=TEXT, font=FONT_BIG)
return lbl
def SubTitle(master, text):
lbl = tk.Label(master, text=text, bg=BG, fg=MUTED, font=FONT_BOLD)
return lbl