File size: 20,476 Bytes
2809163 |
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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# Copyright © 2021 rdbende <rdbende@gmail.com>
# A stunning dark theme for ttk based on Microsoft's Sun Valley visual style
package require Tk 8.6
namespace eval ttk::theme::sun-valley-dark {
variable version 1.0
package provide ttk::theme::sun-valley-dark $version
ttk::style theme create sun-valley-dark -parent clam -settings {
proc load_images {imgdir} {
variable images
foreach file [glob -directory $imgdir *.png] {
set images([file tail [file rootname $file]]) \
[image create photo -file $file -format png]
}
}
load_images [file join [file dirname [info script]] dark]
array set colors {
-fg "#F6F6F7"
-bg "#0e0e0f"
-disabledfg "#F6F6F7"
-selectfg "#ffffff"
-selectbg "#2f60d8"
}
ttk::style layout TButton {
Button.button -children {
Button.padding -children {
Button.label -side left -expand 1
}
}
}
ttk::style layout Toolbutton {
Toolbutton.button -children {
Toolbutton.padding -children {
Toolbutton.label -side left -expand 1
}
}
}
ttk::style layout TMenubutton {
Menubutton.button -children {
Menubutton.padding -children {
Menubutton.label -side left -expand 1
Menubutton.indicator -side right -sticky nsew
}
}
}
ttk::style layout TOptionMenu {
OptionMenu.button -children {
OptionMenu.padding -children {
OptionMenu.label -side left -expand 0
OptionMenu.indicator -side right -sticky nsew
}
}
}
ttk::style layout Accent.TButton {
AccentButton.button -children {
AccentButton.padding -children {
AccentButton.label -side left -expand 1
}
}
}
ttk::style layout Titlebar.TButton {
TitlebarButton.button -children {
TitlebarButton.padding -children {
TitlebarButton.label -side left -expand 1
}
}
}
ttk::style layout Close.Titlebar.TButton {
CloseButton.button -children {
CloseButton.padding -children {
CloseButton.label -side left -expand 1
}
}
}
ttk::style layout TCheckbutton {
Checkbutton.button -children {
Checkbutton.padding -children {
Checkbutton.indicator -side left
Checkbutton.label -side right -expand 1
}
}
}
ttk::style layout Switch.TCheckbutton {
Switch.button -children {
Switch.padding -children {
Switch.indicator -side left
Switch.label -side right -expand 1
}
}
}
ttk::style layout Toggle.TButton {
ToggleButton.button -children {
ToggleButton.padding -children {
ToggleButton.label -side left -expand 1
}
}
}
ttk::style layout TRadiobutton {
Radiobutton.button -children {
Radiobutton.padding -children {
Radiobutton.indicator -side left
Radiobutton.label -side right -expand 1
}
}
}
ttk::style layout Vertical.TScrollbar {
Vertical.Scrollbar.trough -sticky ns -children {
Vertical.Scrollbar.uparrow -side top
Vertical.Scrollbar.downarrow -side bottom
Vertical.Scrollbar.thumb -expand 1
}
}
ttk::style layout Horizontal.TScrollbar {
Horizontal.Scrollbar.trough -sticky ew -children {
Horizontal.Scrollbar.leftarrow -side left
Horizontal.Scrollbar.rightarrow -side right
Horizontal.Scrollbar.thumb -expand 1
}
}
ttk::style layout TSeparator {
TSeparator.separator -sticky nsew
}
ttk::style layout TCombobox {
Combobox.field -sticky nsew -children {
Combobox.padding -expand 1 -sticky nsew -children {
Combobox.textarea -sticky nsew
}
}
null -side right -sticky ns -children {
Combobox.arrow -sticky nsew
}
}
ttk::style layout TSpinbox {
Spinbox.field -sticky nsew -children {
Spinbox.padding -expand 1 -sticky nsew -children {
Spinbox.textarea -sticky nsew
}
}
null -side right -sticky nsew -children {
Spinbox.uparrow -side left -sticky nsew
Spinbox.downarrow -side right -sticky nsew
}
}
ttk::style layout Card.TFrame {
Card.field {
Card.padding -expand 1
}
}
ttk::style layout TLabelframe {
Labelframe.border {
Labelframe.padding -expand 1 -children {
Labelframe.label -side left
}
}
}
ttk::style layout TNotebook {
Notebook.border -children {
TNotebook.Tab -expand 1
Notebook.client -sticky nsew
}
}
ttk::style layout Treeview.Item {
Treeitem.padding -sticky nsew -children {
Treeitem.image -side left -sticky {}
Treeitem.indicator -side left -sticky {}
Treeitem.text -side left -sticky {}
}
}
# Button
ttk::style configure TButton -padding {8 4} -anchor center -foreground $colors(-fg)
ttk::style map TButton -foreground \
[list disabled #7a7a7a \
pressed #d0d0d0]
ttk::style element create Button.button image \
[list $images(button-rest) \
{selected disabled} $images(button-disabled) \
disabled $images(button-disabled) \
selected $images(button-rest) \
pressed $images(button-pressed) \
active $images(button-hover) \
] -border 4 -sticky nsew
# Toolbutton
ttk::style configure Toolbutton -padding {8 4} -anchor center
ttk::style element create Toolbutton.button image \
[list $images(empty) \
{selected disabled} $images(button-disabled) \
selected $images(button-rest) \
pressed $images(button-pressed) \
active $images(button-hover) \
] -border 4 -sticky nsew
# Menubutton
ttk::style configure TMenubutton -padding {8 4 0 4}
ttk::style element create Menubutton.button \
image [list $images(button-rest) \
disabled $images(button-disabled) \
pressed $images(button-pressed) \
active $images(button-hover) \
] -border 4 -sticky nsew
ttk::style element create Menubutton.indicator image $images(arrow-down) -width 28 -sticky {}
# OptionMenu
ttk::style configure TOptionMenu -padding {8 4 0 4}
ttk::style configure OptionMenudropdown -borderwidth 0 -relief ridge
ttk::style element create OptionMenu.button \
image [list $images(button-rest) \
disabled $images(button-disabled) \
pressed $images(button-pressed) \
active $images(button-hover) \
] -border 0 -sticky nsew
ttk::style element create OptionMenu.indicator image $images(arrow-down) -width 28 -sticky {}
# Accent.TButton
ttk::style configure Accent.TButton -padding {8 4} -anchor center -foreground #ffffff
ttk::style map Accent.TButton -foreground \
[list pressed #25536a \
disabled #a5a5a5]
ttk::style element create AccentButton.button image \
[list $images(button-accent-rest) \
{selected disabled} $images(button-accent-disabled) \
disabled $images(button-accent-disabled) \
selected $images(button-accent-rest) \
pressed $images(button-accent-pressed) \
active $images(button-accent-hover) \
] -border 4 -sticky nsew
# Titlebar.TButton
ttk::style configure Titlebar.TButton -padding {8 4} -anchor center -foreground #ffffff
ttk::style map Titlebar.TButton -foreground \
[list disabled #6f6f6f \
pressed #d1d1d1 \
active #ffffff]
ttk::style element create TitlebarButton.button image \
[list $images(empty) \
disabled $images(empty) \
pressed $images(button-titlebar-pressed) \
active $images(button-titlebar-hover) \
] -border 4 -sticky nsew
# Close.Titlebar.TButton
ttk::style configure Close.Titlebar.TButton -padding {8 4} -anchor center -foreground #ffffff
ttk::style map Close.Titlebar.TButton -foreground \
[list disabled #6f6f6f \
pressed #e8bfbb \
active #ffffff]
ttk::style element create CloseButton.button image \
[list $images(empty) \
disabled $images(empty) \
pressed $images(button-close-pressed) \
active $images(button-close-hover) \
] -border 4 -sticky nsew
# Checkbutton
ttk::style configure TCheckbutton -padding 2
ttk::style element create Checkbutton.indicator image \
[list $images(check-unsel-rest) \
{alternate disabled} $images(check-tri-disabled) \
{selected disabled} $images(check-disabled) \
disabled $images(check-unsel-disabled) \
{pressed alternate} $images(check-tri-hover) \
{active alternate} $images(check-tri-hover) \
alternate $images(check-tri-rest) \
{pressed selected} $images(check-hover) \
{active selected} $images(check-hover) \
selected $images(check-rest) \
{pressed !selected} $images(check-unsel-pressed) \
active $images(check-unsel-hover) \
] -width 26 -sticky w
# Switch.TCheckbutton
ttk::style element create Switch.indicator image \
[list $images(switch-off-rest) \
{selected disabled} $images(switch-on-disabled) \
disabled $images(switch-off-disabled) \
{pressed selected} $images(switch-on-pressed) \
{active selected} $images(switch-on-hover) \
selected $images(switch-on-rest) \
{pressed !selected} $images(switch-off-pressed) \
active $images(switch-off-hover) \
] -width 46 -sticky w
# Toggle.TButton
ttk::style configure Toggle.TButton -padding {8 4 8 4} -anchor center -foreground $colors(-fg)
ttk::style map Toggle.TButton -foreground \
[list {selected disabled} #a5a5a5 \
{selected pressed} #d0d0d0 \
selected #ffffff \
pressed #25536a \
disabled #7a7a7a
]
ttk::style element create ToggleButton.button image \
[list $images(button-rest) \
{selected disabled} $images(button-accent-disabled) \
disabled $images(button-disabled) \
{pressed selected} $images(button-rest) \
{active selected} $images(button-accent-hover) \
selected $images(button-accent-rest) \
{pressed !selected} $images(button-accent-rest) \
active $images(button-hover) \
] -border 4 -sticky nsew
# Radiobutton
ttk::style configure TRadiobutton -padding 0
ttk::style element create Radiobutton.indicator image \
[list $images(radio-unsel-rest) \
{selected disabled} $images(radio-disabled) \
disabled $images(radio-unsel-disabled) \
{pressed selected} $images(radio-pressed) \
{active selected} $images(radio-hover) \
selected $images(radio-rest) \
{pressed !selected} $images(radio-unsel-pressed) \
active $images(radio-unsel-hover) \
] -width 20 -sticky w
ttk::style configure Menu.TRadiobutton -padding 0
ttk::style element create Menu.Radiobutton.indicator image \
[list $images(radio-unsel-rest) \
{selected disabled} $images(radio-disabled) \
disabled $images(radio-unsel-disabled) \
{pressed selected} $images(radio-pressed) \
{active selected} $images(radio-hover) \
selected $images(radio-rest) \
{pressed !selected} $images(radio-unsel-pressed) \
active $images(radio-unsel-hover) \
] -width 20 -sticky w
# Scrollbar
#ttk::style layout Vertical.TScrollbar
ttk::style element create Horizontal.Scrollbar.trough image $images(scroll-hor-trough) -sticky ew -border 0
ttk::style element create Horizontal.Scrollbar.thumb image $images(scroll-hor-thumb) -sticky ew -border 3
ttk::style element create Horizontal.Scrollbar.rightarrow image $images(scroll-right) -sticky {} -width 13
ttk::style element create Horizontal.Scrollbar.leftarrow image $images(scroll-left) -sticky {} -width 13
ttk::style element create Vertical.Scrollbar.trough image $images(scroll-vert-trough) -sticky ns -border 0
ttk::style element create Vertical.Scrollbar.thumb image $images(scroll-vert-thumb) -sticky ns -border 3
ttk::style element create Vertical.Scrollbar.uparrow image $images(scroll-up) -sticky {} -height 13
ttk::style element create Vertical.Scrollbar.downarrow image $images(scroll-down) -sticky {} -height 13
# Scale
ttk::style element create Horizontal.Scale.trough image $images(scale-trough-hor) \
-border 5 -padding 0
ttk::style element create Vertical.Scale.trough image $images(scale-trough-vert) \
-border 5 -padding 0
ttk::style element create Scale.slider \
image [list $images(scale-thumb-rest) \
disabled $images(scale-thumb-disabled) \
pressed $images(scale-thumb-pressed) \
active $images(scale-thumb-hover) \
] -sticky {}
# Progressbar
ttk::style element create Horizontal.Progressbar.trough image $images(progress-trough-hor) \
-border 1 -sticky ew
ttk::style element create Horizontal.Progressbar.pbar image $images(progress-pbar-hor) \
-border 2 -sticky ew
ttk::style element create Vertical.Progressbar.trough image $images(progress-trough-vert) \
-border 1 -sticky ns
ttk::style element create Vertical.Progressbar.pbar image $images(progress-pbar-vert) \
-border 2 -sticky ns
# Entry
ttk::style configure TEntry -foreground $colors(-fg)
ttk::style map TEntry -foreground \
[list disabled #757575 \
pressed #cfcfcf
]
ttk::style element create Entry.field \
image [list $images(entry-rest) \
{focus hover !invalid} $images(entry-focus) \
invalid $images(entry-invalid) \
disabled $images(entry-disabled) \
{focus !invalid} $images(entry-focus) \
hover $images(entry-hover) \
] -border 5 -padding 8 -sticky nsew
# Combobox
ttk::style configure TCombobox -foreground $colors(-fg)
ttk::style map TCombobox -foreground \
[list disabled #757575 \
pressed #cfcfcf
]
ttk::style configure TCombobox -foreground $colors(-fg)
ttk::style configure ComboboxPopdownFrame -borderwidth 3 -relief solid
ttk::style map TCombobox -selectbackground [list \
{readonly hover} $colors(-selectbg) \
{readonly focus} $colors(-selectbg) \
] -selectforeground [list \
{readonly hover} $colors(-selectfg) \
{readonly focus} $colors(-selectfg) \
]
ttk::style element create Combobox.field \
image [list $images(button-rest) \
{readonly disabled} $images(button-disabled) \
{readonly pressed} $images(button-pressed) \
{readonly hover} $images(button-hover) \
readonly $images(button-rest) \
invalid $images(entry-invalid) \
disabled $images(entry-disabled) \
focus $images(entry-focus) \
hover $images(button-hover) \
] -border 5 -padding 8 -sticky nsew
ttk::style element create Combobox.arrow image $images(arrow-down) -width 35 -sticky {}
# Spinbox
ttk::style configure TSpinbox -foreground $colors(-fg)
ttk::style map TSpinbox -foreground \
[list disabled #757575 \
pressed #cfcfcf
]
ttk::style element create Spinbox.field \
image [list $images(entry-rest) \
invalid $images(entry-invalid) \
disabled $images(entry-disabled) \
focus $images(entry-focus) \
hover $images(entry-hover) \
] -border 5 -padding {8 8 54 8} -sticky nsew
ttk::style element create Spinbox.uparrow image $images(arrow-up) -width 35 -sticky {}
ttk::style element create Spinbox.downarrow image $images(arrow-down) -width 35 -sticky {}
# Sizegrip
ttk::style element create Sizegrip.sizegrip image $images(sizegrip) \
-sticky nsew
# Separator
ttk::style element create TSeparator.separator image $images(separator)
# Card
ttk::style element create Card.field image $images(card) \
-border 10 -padding 4 -sticky nsew
# Labelframe
ttk::style element create Labelframe.border image $images(card) \
-border 5 -padding 4 -sticky nsew
# Notebook
ttk::style configure TNotebook -padding 1
ttk::style element create Notebook.border \
image $images(notebook-border) -border 5 -padding 5
ttk::style element create Notebook.client image $images(notebook)
ttk::style element create Notebook.tab \
image [list $images(tab-rest) \
selected $images(tab-selected) \
active $images(tab-hover) \
] -border 13 -padding {16 14 16 6} -height 32
# Treeview
ttk::style element create Treeview.field image $images(card) \
-border 5
ttk::style element create Treeheading.cell \
image [list $images(treeheading-rest) \
pressed $images(treeheading-pressed) \
active $images(treeheading-hover)
] -border 5 -padding 15 -sticky nsew
ttk::style element create Treeitem.indicator \
image [list $images(arrow-right) \
user2 $images(empty) \
user1 $images(arrow-down) \
] -width 26 -sticky {}
ttk::style configure Treeview -background $colors(-bg) -rowheight [expr {[font metrics font -linespace] + 2}]
ttk::style map Treeview \
-background [list selected #292929] \
-foreground [list selected $colors(-selectfg)]
# Panedwindow
# Insane hack to remove clam's ugly sash
ttk::style configure Sash -gripcount 0
}
} |