Artifact
1c4c23d98f8a8811ad720851a9c666dcb25ac3907a5974a05114ecc5ab42192c:
Attachment "themes.tcl" to
ticket [fe932e45]
added by
nemethi
2026-07-13 15:58:39.
#! /usr/bin/env tclsh
package require Tk
tk scaling 2.0
if {[tk windowingsystem] in {aqua x11}} {
foreach font [font names] {
set size [font actual $font -size]
font configure $font -size [expr {round(1.5 * $size)}]
}
}
set origTheme [expr {$argc == 0 ? [ttk::style theme use] : [lindex $argv 0]}]
set off 0
set on 1
set num 55
ttk::frame .f
ttk::notebook .nb
ttk::labelframe .lf
.nb add .lf -padding 7.5p
ttk::frame .junk
.nb add .junk
ttk::frame .mbf
ttk::label .l -textvariable txt
ttk::menubutton .mb -menu .mb.m -textvariable txt
menu .mb.m -tearoff 0
### set themeList [ttk::style theme names] ;# built-in themes only
set themeList [ttk::themes] ;# third-party themes, too
foreach theme [lsort -dictionary $themeList] {
.mb.m add command -label $theme -command [list setTheme $theme]
}
proc setTheme theme {
ttk::setTheme $theme
set ::txt $theme
.nb tab .lf -text $theme
.nb tab .junk -text [join [lreverse [split $theme {}]] {}]
.lf configure -text " $theme "
set bg [ttk::style lookup . -background]
set fg [ttk::style lookup . -foreground {} black]
.mb.m configure -background $bg -foreground $fg
foreach opt {-activebackground -activeborderwidth -activeforeground
-borderwidth -relief} {
set defaultVal [lindex [.mb.m configure $opt] 3]
.mb.m configure $opt $defaultVal
}
}
setTheme $origTheme
pack .l .mb -in .mbf -side left -padx 3p -expand true -fill x
ttk::combobox .combo -values [list aaa bbb ccc] -textvariable txt -width 15
ttk::frame .cbf
ttk::checkbutton .cboff -text off -variable off
ttk::checkbutton .cbon -text on -variable on
ttk::toggleswitch .tsw -variable on
pack .cboff .cbon .tsw -in .cbf -side left -padx 3p
ttk::separator .sep
ttk::frame .rbf
ttk::radiobutton .rboff -text off -variable on -value 0
ttk::radiobutton .rbon -text on -variable on -value 1
pack .rboff .rbon -in .rbf -side left -padx 3p
ttk::scale .sc -from 0 -to 100 -variable num
ttk::progressbar .pb -mode determinate -variable num
ttk::spinbox .sbox1 -style TSpinbox -to 100 -textvariable num -width 5
ttk::spinbox .sbox2 -style Wide.TSpinbox -to 100 -textvariable num -width 5
ttk::entry .ent -textvariable txt -width 15
### ttk::sizegrip .sg
ttk::scrollbar .sb; .sb set 0.3 0.7
pack .mbf .combo .cbf .sep .rbf .sc .pb .sbox1 .sbox2 .ent \
-in .lf -side top -anchor w -padx 6p -pady 3p
pack configure .mbf .cbf .rbf -padx 3p
pack configure .sep -fill x
### pack .sg -in .lf -side right -anchor s
pack .sb -in .f -side right -fill y -padx {0 7.5p} -pady 7.5p
pack .nb -in .f -side left -expand true -fill both -padx 7.5p -pady 7.5p
pack .f -expand true -fill both