Skip to content

Commit

Permalink
Fix some fonts on Windows, tweak colors and widget height
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Dec 3, 2022
1 parent 742d545 commit 4135dae
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 47 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="sv_ttk",
version="2.2",
version="2.3",
license="MIT",
author="rdbende",
author_email="[email protected]",
Expand Down
38 changes: 28 additions & 10 deletions sv.tcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
package require Tk 8.6

if {[tk windowingsystem] == "win32"} {
set static ""
} else {
set static " static"
}

font create SunValleyCaptionFont -family "Segoe UI Variable$static Small" -size -12
font create SunValleyBodyFont -family "Segoe UI Variable$static Text" -size -14
font create SunValleyBodyStrongFont -family "Segoe UI Variable$static Text Semibold" -size -14
font create SunValleyBodyLargeFont -family "Segoe UI Variable$static Text" -size -18
font create SunValleySubtitleFont -family "Segoe UI Variable$static Display Semibold" -size -20
font create SunValleyTitleFont -family "Segoe UI Variable$static Display Semibold" -size -28
font create SunValleyTitleLargeFont -family "Segoe UI Variable$static Display Semibold" -size -40
font create SunValleyDisplayFont -family "Segoe UI Variable$static Display Semibold" -size -68

proc config_input_font {w} {
if {[ttk::style theme use] in [list "sun-valley-dark" "sun-valley-light"]} {
$w configure -font SunValleyBodyFont
}
}

bind TEntry <<ThemeChanged>> {config_input_font %W}
bind TCombobox <<ThemeChanged>> {config_input_font %W}
bind TSpinbox <<ThemeChanged>> {config_input_font %W}


source [file join [file dirname [info script]] theme light.tcl]
source [file join [file dirname [info script]] theme dark.tcl]

Expand Down Expand Up @@ -66,13 +94,3 @@ proc set_theme {mode} {
option add *Menu.selectColor $ttk::theme::sv_light::theme_colors(-fg)
}
}


font create SunValleyCaptionFont -family "Segoe UI Variable Static Small" -size -12
font create SunValleyBodyFont -family "Segoe UI Variable Static Text" -size -14
font create SunValleyBodyStrongFont -family "Segoe UI Variable Static Text Semibold" -size -14
font create SunValleyBodyLargeFont -family "Segoe UI Variable Static Text" -size -18
font create SunValleySubtitleFont -family "Segoe UI Variable Static Display Semibold" -size -20
font create SunValleyTitleFont -family "Segoe UI Variable Static Display Semibold" -size -28
font create SunValleyTitleLargeFont -family "Segoe UI Variable Static Display Semibold" -size -40
font create SunValleyDisplayFont -family "Segoe UI Variable Static Display Semibold" -size -68
33 changes: 16 additions & 17 deletions theme/dark.tcl
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package require Tk 8.6
source [file join [file dirname [info script]] sprites_dark.tcl]

namespace eval ttk::theme::sv_dark {
package provide ttk::theme::sv_dark 2.0
package provide ttk::theme::sv_dark 2.3

array set theme_colors {
-fg "#ffffff"
-fg "#fafafa"
-bg "#1c1c1c"
-disfg "#595959"
-selfg "#ffffff"
Expand Down Expand Up @@ -35,7 +34,7 @@ namespace eval ttk::theme::sv_dark {
}
}

ttk::style configure TButton -padding {8 4} -anchor center -foreground $theme_colors(-fg)
ttk::style configure TButton -padding {8 2 8 3} -anchor center -foreground $theme_colors(-fg)
ttk::style map TButton -foreground [list disabled "#7a7a7a" pressed "#d0d0d0"]

ttk::style element create Button.button image \
Expand All @@ -58,7 +57,7 @@ namespace eval ttk::theme::sv_dark {
}
}

ttk::style configure Toolbutton -padding {8 4} -anchor center
ttk::style configure Toolbutton -padding {8 2 8 3} -anchor center

ttk::style element create Toolbutton.button image \
[list $I(empty) \
Expand All @@ -78,7 +77,7 @@ namespace eval ttk::theme::sv_dark {
}
}

ttk::style configure Accent.TButton -padding {8 4} -anchor center -foreground "#000000"
ttk::style configure Accent.TButton -padding {8 2 8 3} -anchor center -foreground "#000000"
ttk::style map Accent.TButton -foreground [list pressed "#25536a" disabled "#a5a5a5"]

ttk::style element create AccentButton.button image \
Expand All @@ -102,7 +101,7 @@ namespace eval ttk::theme::sv_dark {
}
}

ttk::style configure TMenubutton -padding {8 4 10 4}
ttk::style configure TMenubutton -padding {8 2 13 3}

ttk::style element create Menubutton.button image \
[list $I(button-rest) \
Expand All @@ -125,7 +124,7 @@ namespace eval ttk::theme::sv_dark {
}
}

ttk::style configure TOptionMenu -padding {8 4 10 4}
ttk::style configure TOptionMenu -padding {8 2 13 3}

ttk::style element create OptionMenu.button image \
[list $I(button-rest) \
Expand Down Expand Up @@ -205,7 +204,7 @@ namespace eval ttk::theme::sv_dark {
}
}

ttk::style configure Toggle.TButton -padding {8 4 8 4} -anchor center -foreground $theme_colors(-fg)
ttk::style configure Toggle.TButton -padding {8 2 8 3} -anchor center -foreground $theme_colors(-fg)

ttk::style map Toggle.TButton -foreground \
[list {selected disabled} "#a5a5a5" \
Expand Down Expand Up @@ -258,7 +257,7 @@ namespace eval ttk::theme::sv_dark {
] -width 26 -sticky w

# Entry
ttk::style configure TEntry -foreground $theme_colors(-fg) -font SunValleyBodyFont
ttk::style configure TEntry -foreground $theme_colors(-fg) -padding {6 1 4 2}
ttk::style map TEntry -foreground [list disabled "#757575" pressed "#cfcfcf"]

ttk::style element create Entry.field image \
Expand All @@ -268,7 +267,7 @@ namespace eval ttk::theme::sv_dark {
disabled $I(textbox-dis) \
{focus !invalid} $I(textbox-focus) \
hover $I(textbox-hover) \
] -border 5 -padding 8 -sticky nsew
] -border 5 -sticky nsew

# Combobox
ttk::style layout TCombobox {
Expand All @@ -280,7 +279,7 @@ namespace eval ttk::theme::sv_dark {
}
}

ttk::style configure TCombobox -foreground $theme_colors(-fg) -font SunValleyBodyFont
ttk::style configure TCombobox -foreground $theme_colors(-fg) -padding {6 1 0 2}
ttk::style configure ComboboxPopdownFrame -borderwidth 1 -relief solid
ttk::style map TCombobox -foreground [list disabled "#757575" pressed "#cfcfcf"]

Expand All @@ -305,7 +304,7 @@ namespace eval ttk::theme::sv_dark {
focus $I(textbox-focus) \
{focus !invalid} $I(textbox-focus) \
hover $I(textbox-hover) \
] -border 5 -padding {8 8 2 8}
] -border 5

ttk::style element create Combobox.arrow image $I(down) -width 34 -sticky {}

Expand All @@ -320,7 +319,7 @@ namespace eval ttk::theme::sv_dark {
}
}

ttk::style configure TSpinbox -foreground $theme_colors(-fg) -font SunValleyBodyFont
ttk::style configure TSpinbox -foreground $theme_colors(-fg) -padding {6 1 0 2}
ttk::style map TSpinbox -foreground [list disabled "#757575" pressed "#cfcfcf"]

ttk::style element create Spinbox.field image \
Expand All @@ -331,7 +330,7 @@ namespace eval ttk::theme::sv_dark {
focus $I(textbox-focus) \
{focus !invalid} $I(textbox-focus) \
hover $I(textbox-hover) \
] -border 5 -padding {8 8 2 8} -sticky nsew
] -border 5 -sticky nsew

ttk::style element create Spinbox.uparrow image $I(up) -width 34 -height 16 -sticky {}
ttk::style element create Spinbox.downarrow image $I(down) -width 34 -height 16 -sticky {}
Expand Down Expand Up @@ -413,7 +412,7 @@ namespace eval ttk::theme::sv_dark {
}

ttk::style element create Labelframe.border image $I(card) -border 5 -padding 4 -sticky nsew
ttk::style configure TLabelframe.Label -font SunValleyBodyFont
ttk::style configure TLabelframe.Label -font SunValleyBodyStrongFont -foreground "#9e9e9e"

# Notebook
ttk::style layout TNotebook {
Expand All @@ -433,7 +432,7 @@ namespace eval ttk::theme::sv_dark {
] -border 13 -padding {16 14 16 6} -height 32

# Treeview
ttk::style configure Treeview -background $theme_colors(-bg) -rowheight [expr {[font metrics font -linespace] + 2}]
ttk::style configure Treeview -background $theme_colors(-bg) -rowheight [expr {[font metrics SunValleyBodyFont -linespace] + 4}] -font SunValleyCaptionFont
ttk::style map Treeview \
-background [list selected "#292929"] \
-foreground [list selected $theme_colors(-selfg)]
Expand Down
37 changes: 18 additions & 19 deletions theme/light.tcl
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package require Tk 8.6
source [file join [file dirname [info script]] sprites_light.tcl]

namespace eval ttk::theme::sv_light {
package provide ttk::theme::sv_light 2.0
package provide ttk::theme::sv_light 2.3

array set theme_colors {
-fg "#000000"
-fg "#1c1c1c"
-bg "#fafafa"
-disfg "#a0a0a0"
-selfg "#ffffff"
Expand Down Expand Up @@ -35,7 +34,7 @@ namespace eval ttk::theme::sv_light {
}
}

ttk::style configure TButton -padding {8 4} -anchor center -foreground $theme_colors(-fg)
ttk::style configure TButton -padding {8 2 8 3} -anchor center -foreground $theme_colors(-fg)
ttk::style map TButton -foreground [list disabled "#a2a2a2" pressed "#636363" active "#1a1a1a"]

ttk::style element create Button.button image \
Expand All @@ -58,7 +57,7 @@ namespace eval ttk::theme::sv_light {
}
}

ttk::style configure Toolbutton -padding {8 4} -anchor center
ttk::style configure Toolbutton -padding {8 2 8 3} -anchor center

ttk::style element create Toolbutton.button image \
[list $I(empty) \
Expand All @@ -78,7 +77,7 @@ namespace eval ttk::theme::sv_light {
}
}

ttk::style configure Accent.TButton -padding {8 4} -anchor center -foreground "#ffffff"
ttk::style configure Accent.TButton -padding {8 2 8 3} -anchor center -foreground "#ffffff"
ttk::style map Accent.TButton -foreground [list pressed "#c1d8ee" disabled "#ffffff"]

ttk::style element create AccentButton.button image \
Expand All @@ -102,7 +101,7 @@ namespace eval ttk::theme::sv_light {
}
}

ttk::style configure TMenubutton -padding {8 4 10 4}
ttk::style configure TMenubutton -padding {8 2 13 3}

ttk::style element create Menubutton.button image \
[list $I(button-rest) \
Expand All @@ -125,7 +124,7 @@ namespace eval ttk::theme::sv_light {
}
}

ttk::style configure TOptionMenu -padding {8 4 10 4}
ttk::style configure TOptionMenu -padding {8 2 13 3}

ttk::style element create OptionMenu.button image \
[list $I(button-rest) \
Expand Down Expand Up @@ -205,7 +204,7 @@ namespace eval ttk::theme::sv_light {
}
}

ttk::style configure Toggle.TButton -padding {8 4 8 4} -anchor center -foreground $theme_colors(-fg)
ttk::style configure Toggle.TButton -padding {8 2 8 3} -anchor center -foreground $theme_colors(-fg)

ttk::style map Toggle.TButton -foreground \
[list {selected disabled} "#ffffff" \
Expand Down Expand Up @@ -259,7 +258,7 @@ namespace eval ttk::theme::sv_light {
] -width 26 -sticky w

# Entry
ttk::style configure TEntry -foreground $theme_colors(-fg) -font SunValleyBodyFont
ttk::style configure TEntry -foreground $theme_colors(-fg) -padding {6 1 4 2}
ttk::style map TEntry -foreground [list disabled "#0a0a0a" pressed "#636363" active "#626262"]

ttk::style element create Entry.field image \
Expand All @@ -269,7 +268,7 @@ namespace eval ttk::theme::sv_light {
disabled $I(textbox-dis) \
{focus !invalid} $I(textbox-focus) \
hover $I(textbox-hover) \
] -border 5 -padding 8 -sticky nsew
] -border 5 -sticky nsew

# Combobox
ttk::style layout TCombobox {
Expand All @@ -281,7 +280,7 @@ namespace eval ttk::theme::sv_light {
}
}

ttk::style configure TCombobox -foreground $theme_colors(-fg) -font SunValleyBodyFont
ttk::style configure TCombobox -foreground $theme_colors(-fg) -padding {6 1 0 2}
ttk::style configure ComboboxPopdownFrame -borderwidth 1 -relief solid
ttk::style map TCombobox -foreground [list disabled "#0a0a0a" pressed "#636363" active "#626262"]

Expand All @@ -306,8 +305,8 @@ namespace eval ttk::theme::sv_light {
focus $I(textbox-focus) \
{focus !invalid} $I(textbox-focus) \
hover $I(textbox-hover) \
] -border 5 -padding {8 8 2 8}
] -border 5

ttk::style element create Combobox.arrow image $I(down) -width 34 -sticky {}

# Spinbox
Expand All @@ -321,7 +320,7 @@ namespace eval ttk::theme::sv_light {
}
}

ttk::style configure TSpinbox -foreground $theme_colors(-fg) -font SunValleyBodyFont
ttk::style configure TSpinbox -foreground $theme_colors(-fg) -padding {6 1 0 2}
ttk::style map TSpinbox -foreground [list disabled "#0a0a0a" pressed "#636363" active "#626262"]

ttk::style element create Spinbox.field image \
Expand All @@ -332,7 +331,7 @@ namespace eval ttk::theme::sv_light {
focus $I(textbox-focus) \
{focus !invalid} $I(textbox-focus) \
hover $I(textbox-hover) \
] -border 5 -padding {8 8 2 8} -sticky nsew
] -border 5 -sticky nsew

ttk::style element create Spinbox.uparrow image $I(up) -width 34 -height 16 -sticky {}
ttk::style element create Spinbox.downarrow image $I(down) -width 34 -height 16 -sticky {}
Expand Down Expand Up @@ -414,7 +413,7 @@ namespace eval ttk::theme::sv_light {
}

ttk::style element create Labelframe.border image $I(card) -border 5 -padding 4 -sticky nsew
ttk::style configure TLabelframe.Label -font SunValleyBodyStrongFont
ttk::style configure TLabelframe.Label -font SunValleyBodyStrongFont -foreground "#676767"

# Notebook
ttk::style layout TNotebook {
Expand All @@ -434,9 +433,9 @@ namespace eval ttk::theme::sv_light {
] -border 13 -padding {16 14 16 6} -height 32

# Treeview
ttk::style configure Treeview -background $theme_colors(-bg) -rowheight [expr {[font metrics font -linespace] + 2}]
ttk::style configure Treeview -background $theme_colors(-bg) -rowheight [expr {[font metrics SunValleyBodyFont -linespace] + 4}] -font SunValleyCaptionFont
ttk::style map Treeview \
-background [list selected "#f0f0f0"] \
-background [list selected "#e7e7e7"] \
-foreground [list selected "#191919"]

ttk::style element create Treeview.field image $I(card) -border 5 -width 0 -height 0
Expand Down

0 comments on commit 4135dae

Please sign in to comment.