palette(3pm)
π palette(3pm) β bestie edition π
okay so this is the page for Tk::palette, aka the thing that lets you Modify the Tk color palette. yes. the whole vibe. we're redecorating β¨
πΈ SYNOPSIS πΈ
$widget->setPalette(background)
$widget->setPalette(name=>value?,name=>value ...?)
$widget->bisque
π DESCRIPTION π
so setPalette is the method that changes the color scheme for Tk. iconic behavior tbh. it does this in two ways at once: it modifies the colors of widgets that already exist, and it changes the option database so that future widgets will use the new color scheme. slay.
if setPalette gets called with a single argument, that argument is the name of a color to use as the normal background color, and setPalette will compute a complete color palette from this background color. one color in, whole fit out. π¦
alternatively, the arguments to setPalette may consist of any number of name-value pairs, where the first argument of the pair is the name of an option in the Tk option database and the second argument is the new value to use for that option.
these are the database names currently supported π
activeBackground foreground selectColor
activeForeground highlightBackground selectBackground
background highlightColor selectForeground
disabledForeground insertBackground troughColor
setPalette tries to compute reasonable defaults for any options that you don't specify. no thoughts, just reasonable defaults π
and listen β you can specify options other than the above ones and Tk will change those options on widgets as well. that feature may be useful if you're using custom widgets with additional color options. main character custom widget energy, we love to see it.
once it has computed the new value to use for each of the color options, setPalette scans the widget hierarchy to modify the options of all existing widgets. for each widget, it checks to see if any of the above options is defined for the widget. if so, and if the option's current value is the default, then the value is changed; if the option has a value other than the default, setPalette will not change it. boundaries! respected!
the default for an option is the one provided by the widget β ($w->configure('option'))[3] β unless setPalette has been run previously, in which case it is the value specified in the previous invocation of setPalette. iykyk.
after modifying all the widgets in the application, setPalette adds options to the option database to change the defaults for widgets created in the future. the new options are added at priority widgetDefault, so they will be overridden by options from the .Xdefaults file or options specified on the command-line that creates a widget. so like, future widgets get the new look, but your .Xdefaults still has the final say. periodt.
the method bisque is provided for backward compatibility: it restores the application's colors to the light brown (bisque) color scheme used in Tk 3.6 and earlier versions. throwback. vintage. grandmacore π
π BUGS π
- the use of option database names rather than the configure names is understandable given the mechanism (copied from Tcl/Tk), but is potentially confusing. not me getting confused by my own manpage π
- the interpolation of different 'shades' of color used for 3D effects in 'RGB' space can lead to undesirable changes in 'hue'. interpolation in 'HSV' (as used in
Tk::ColorEditor) would be more robust and X11R5's color support probably even more so. ngl the hue shift is giving unhinged.
π«Ά SEE ALSO π«Ά
Tk::options
β KEYWORDS β
bisque, color, palette
and that's the whole page bestie, you ate that π β¨ this was perl v5.40.1, dated 2025-04-13 β go forth and recolor the entire app, you've got this ππ
π¦ where this page comes from
- debian trixie: perl-tk 1:804.036+dfsg1-5
- ubuntu questing: perl-tk 1:804.036+dfsg1-5
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms