Skip to content

Commit e6ccdb2

Browse files
committed
preparation of new themes
1 parent 7240b48 commit e6ccdb2

File tree

57 files changed

+10432
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+10432
-7
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
package require Tk 8.6
2+
3+
# Source theme files in a loop for efficiency and maintainability
4+
set themes [list sunny-yellow_light sunny-yellow_dark moonstone_light moonstone_dark dark-red_light dark-red_dark liver_light liver_dark yellow-green_light yellow-green_dark payne's-gray_light payne's-gray_dark hunter-green_light hunter-green_dark sky-magenta_light sky-magenta_dark l-see-green_light l-see-green_dark]
5+
foreach theme $themes {
6+
source [file join [file dirname [info script]] theme $theme.tcl]
7+
}
8+
9+
if {[tk windowingsystem] == "win32"} {
10+
set static ""
11+
} elseif {[tk windowingsystem] == "x11"} {
12+
set static "static"
13+
} else {
14+
set static "" # macOS and other systems
15+
}
16+
17+
font create SVCaptionFont -family "Arial Rounded MT Bold" -size -12
18+
font create SVBodyFont -family "Arial Rounded MT Bold" -size -14
19+
font create SVBodyStrongFont -family "Arial Rounded MT Bold" -weight bold -size -14
20+
font create SVBodyLargeFont -family "Arial Rounded MT Bold" -size -18
21+
font create SVSubtitleFont -family "Arial Rounded MT Bold" -weight bold -size -20
22+
font create SVTitleFont -family "Arial Rounded MT Bold" -weight bold -size -28
23+
font create SVTitleLargeFont -family "Arial Rounded MT Bold" -weight bold -size -40
24+
font create SVDisplayFont -family "Arial Rounded MT Bold" -weight bold -size -68
25+
26+
27+
proc config_entry_font {w} {
28+
set font_config [$w config -font]
29+
if {[lindex $font_config 3] != [lindex $font_config 4]} {
30+
return
31+
}
32+
if {[ttk::style theme use] in {"sunny-yellow_dark", "moonstone_dark", "dark-red_dark", "beaver_dark", "liver_dark", "yellow-green_dark", "payne's-gray_dark", "hunter-green_dark", "sky-magenta_dark", "l-see-green_dark", "middle-gy_dark",
33+
"sunny-yellow_light", "moonstone_light", "dark-red_light", "beaver_light", "liver_light", "yellow-green_light", "payne's-gray_light", "hunter-green_light", "sky-magenta_light", "l-see-green_light", "middle-gy_light"}} {
34+
$w configure -font SVBodyFont
35+
}
36+
}
37+
38+
39+
proc config_menus {w} {
40+
if {[tk windowingsystem] == "aqua" || [tk windowingsystem] == "win32"} {
41+
return
42+
}
43+
44+
set theme [ttk::style theme use]
45+
if {$theme == "sunny-yellow_dark" || $theme == "moonstone_dark" || $theme == "dark-red_dark" || $theme == "beaver_dark" || $theme == "liver_dark" || $theme == "yellow-green_dark" || $theme == "payne's-gray_dark" || $theme == "hunter-green_dark" || $theme == "sky-magenta_dark" || $theme == "l-see-green_dark" || $theme == "middle-gy_dark"} {
46+
$w configure \
47+
-relief solid \
48+
-borderwidth 1 \
49+
-activeborderwidth 0 \
50+
-background "#292929" \
51+
-activebackground $ttk::theme::sv_dark::colors(-selbg) \
52+
-activeforeground $ttk::theme::sv_dark::colors(-selfg) \
53+
-selectcolor $ttk::theme::sv_dark::colors(-selfg)
54+
} elseif {$theme == "sunny-yellow_light" || $theme == "moonstone_light" || $theme == "dark-red_light" || $theme == "beaver_light" || $theme == "liver_light" || $theme == "yellow-green_light" || $theme == "payne's-gray_light" || $theme == "hunter-green_light" || $theme == "sky-magenta_light" || $theme == "l-see-green_light" || $theme == "middle-gy_light"} {
55+
$w configure \
56+
-relief solid \
57+
-borderwidth 1 \
58+
-activeborderwidth 0 \
59+
-background "#e7e7e7" \
60+
-activebackground $ttk::theme::sv_dark::colors(-selbg) \
61+
-activeforeground $ttk::theme::sv_dark::colors(-selfg) \
62+
-selectcolor $ttk::theme::sv_dark::colors(-selfg)
63+
}
64+
65+
if {[[winfo toplevel $w] cget -menu] != $w} {
66+
if {$theme == "sunny-yellow_dark" || $theme == "moonstone_dark" || $theme == "dark-red_dark" || $theme == "beaver_dark" || $theme == "liver_dark" || $theme == "yellow-green_dark" || $theme == "payne's-gray_dark" || $theme == "hunter-green_dark" || $theme == "sky-magenta_dark" || $theme == "l-see-green_dark" || $theme == "middle-gy_dark"} {
67+
$w configure -borderwidth 0 -background $ttk::theme::sv_dark::colors(-bg)
68+
} elseif {$theme == "sunny-yellow_light" || $theme == "moonstone_light" || $theme == "dark-red_light" || $theme == "beaver_light" || $theme == "liver_light" || $theme == "yellow-green_light" || $theme == "payne's-gray_light" || $theme == "hunter-green_light" || $theme == "sky-magenta_light" || $theme == "l-see-green_light" || $theme == "middle-gy_light"} {
69+
$w configure -borderwidth 0 -background $ttk::theme::sv_light::colors(-bg)
70+
}
71+
}
72+
}
73+
74+
75+
proc configure_colors {} {
76+
set theme [ttk::style theme use]
77+
if {$theme == "sunny-yellow_dark" || $theme == "moonstone_dark" || $theme == "dark-red_dark" || $theme == "beaver_dark" || $theme == "liver_dark" || $theme == "yellow-green_dark" || $theme == "payne's-gray_dark" || $theme == "hunter-green_dark" || $theme == "sky-magenta_dark" || $theme == "l-see-green_dark" || $theme == "middle-gy_dark"} {
78+
ttk::style configure . \
79+
-background $ttk::theme::sv_dark::colors(-bg) \
80+
-foreground $ttk::theme::sv_dark::colors(-fg) \
81+
-troughcolor $ttk::theme::sv_dark::colors(-bg) \
82+
-focuscolor $ttk::theme::sv_dark::colors(-selbg) \
83+
-selectbackground $ttk::theme::sv_dark::colors(-selbg) \
84+
-selectforeground $ttk::theme::sv_dark::colors(-selfg) \
85+
-insertwidth 1 \
86+
-insertcolor $ttk::theme::sv_dark::colors(-fg) \
87+
-fieldbackground $ttk::theme::sv_dark::colors(-bg) \
88+
-font SVBodyFont \
89+
-borderwidth 0 \
90+
-relief flat
91+
92+
tk_setPalette \
93+
background $ttk::theme::sv_dark::colors(-bg) \
94+
foreground $ttk::theme::sv_dark::colors(-fg) \
95+
highlightColor $ttk::theme::sv_dark::colors(-selbg) \
96+
selectBackground $ttk::theme::sv_dark::colors(-selbg) \
97+
selectForeground $ttk::theme::sv_dark::colors(-selfg) \
98+
activeBackground $ttk::theme::sv_dark::colors(-selbg) \
99+
activeForeground $ttk::theme::sv_dark::colors(-selfg)
100+
101+
ttk::style map . -foreground [list disabled $ttk::theme::sv_dark::colors(-disfg)]
102+
} elseif {$theme == "sunny-yellow_light" || $theme == "moonstone_light" || $theme == "dark-red_light" || $theme == "beaver_light" || $theme == "liver_light" || $theme == "yellow-green_light" || $theme == "payne's-gray_light" || $theme == "hunter-green_light" || $theme == "sky-magenta_light" || $theme == "l-see-green_light" || $theme == "middle-gy_light"} {
103+
ttk::style configure . \
104+
-background $ttk::theme::sv_light::colors(-bg) \
105+
-foreground $ttk::theme::sv_light::colors(-fg) \
106+
-troughcolor $ttk::theme::sv_light::colors(-bg) \
107+
-focuscolor $ttk::theme::sv_light::colors(-selbg) \
108+
-selectbackground $ttk::theme::sv_light::colors(-selbg) \
109+
-selectforeground $ttk::theme::sv_light::colors(-selfg) \
110+
-insertwidth 1 \
111+
-insertcolor $ttk::theme::sv_light::colors(-fg) \
112+
-fieldbackground $ttk::theme::sv_light::colors(-bg) \
113+
-font SVBodyFont \
114+
-borderwidth 0 \
115+
-relief flat
116+
117+
tk_setPalette \
118+
background $ttk::theme::sv_light::colors(-bg) \
119+
foreground $ttk::theme::sv_light::colors(-fg) \
120+
highlightColor $ttk::theme::sv_light::colors(-selbg) \
121+
selectBackground $ttk::theme::sv_light::colors(-selbg) \
122+
selectForeground $ttk::theme::sv_light::colors(-selfg) \
123+
activeBackground $ttk::theme::sv_light::colors(-selbg) \
124+
activeForeground $ttk::theme::sv_light::colors(-selfg)
125+
126+
ttk::style map . -foreground [list disabled $ttk::theme::sv_light::colors(-disfg)]
127+
}
128+
}
129+
130+
131+
bind [winfo class .] <<ThemeChanged>> {+configure_colors}
132+
bind TEntry <<ThemeChanged>> {+config_entry_font %W}
133+
bind TCombobox <<ThemeChanged>> {+config_entry_font %W}
134+
bind TSpinbox <<ThemeChanged>> {+config_entry_font %W}
135+
bind Menu <<ThemeChanged>> {+config_menus %W}

OU Dictionary Editor/Assets/modules/sv_ttk/sv_ttk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ def toggle_theme(root: tkinter.Tk | None = None) -> None:
4949

5050

5151
use_dark_theme = partial(set_theme, "dark")
52-
use_light_theme = partial(set_theme, "light")
52+
use_light_theme = partial(set_theme, "light")

0 commit comments

Comments
 (0)