Tk color picker a bit modified and explained

Tk color picker

The native Tk color picker (tk_chooseColor) is used in Unix platforms as they have no default color picker, while Windows and Mac OS have.

Probably tk_chooseColor looks like an ugly duckling among its tough 'Big Brothers'. Though, the Windows' color picker is somewhat cumbersome, except for its toning bar which is very good feature. Of course the coolest of all is Mac OS' color picker implementing the color circle.

Nevertheless, I would try and show some remarkable features of tk_chooseColor which are enhanced with my little changes, available here:

http://chiselapp.com/user/aplsimple/repository/tkcc/download

https://aplsimple.github.io/files/tkcolorpicker.rar

The changes are seen on the screenshots:

Tk color picker a bit modified

Stand-alone Tk color picker

... and on the video (3.5 Mb):

https://aplsimple.github.io/files/tkcolorpicker.mp4

The changes to tk_chooseColor are the following:

1. The resizing of window is locked (supposedly the resizing makes no sense, at least in the current version of tk_chooseColor).

2. The default sizes of Tk color picker are changed a little for more usability.

3. The 'Move all' checkbox is added allowing to move all (R, G, B) selectors simultaneously.

4. The 'Tone moves' checkbox is added allowing to implement the toning feature for a current color.

5. The RGBCMY and their tones are added, in separate color boxes.

6. The -moveall (0 by defauls) and -tonemoves (1 by default) options are added.

7. The chooser is themed now. For comparison, two themed choosers are shown beside on the screenshot.

8. A stand-alone Tk color chooser is available (1st screenshot above). Invoked with: tclsh tkclr.tcl.

Useful features of tk_chooseColor

Before exploring a usage example of tk_chooseColor, let's consider few features of tk_chooseColor that are not too obvious.

1. In tk_chooseColor you can move (and would find it very convenient) any selector with clicking and dragging the mouse over the color bars. See the example of this on the video.

2. You can input a Tk standard color name in the entry field. This feature is also demonstrated on the video. Here:

https://www.tcl-lang.org/man/tcl8.6/TkCmd/colors.htm

you can see all Tk standard colors sorted by names.

And here:

https://aplsimple.github.io/en/tcl/tkcc/tkcolors-sorted-by-red.txt

https://aplsimple.github.io/en/tcl/tkcc/tkcolors-sorted-by-green.txt

https://aplsimple.github.io/en/tcl/tkcc/tkcolors-sorted-by-blue.txt

you can see all Tk standard colors sorted by Red, Green and Blue values.

These sortings are useful when you need to view some analogous colors that are close to each other by not their names but hues.

3. Using only three 'magic' numbers (0, 128, 255) you can get a combination of 27 colors which are nearly all you need - primary, secondary and tertiary ones. All those red, green, blue, cyan, magenta, yellow, olive, purple, teal etc. and their tones.

But what makes tk_chooseColor so remarkable is that you can easily see and access all neighboring colors for the selected one. They are located at both sides of tk_chooseColor's selectors.

For example, in tk_chooseColor you can easily locate the brownish range of colors (terra incognita for some color pickers). At that, it's enough to know that brown contains no blue. You can simply enter brown in the entry field and tone the hue as well. See the mentioned video demoing it.

4. The tk_chooseColor is very helpful in the designing of color schemes, e.g. for your applications or themed editors.

The example of theming is considered below.

Applying Tk color picker to a color design

Here we would develop the color theme for TKE editor written in pure Tcl/Tk btw.

For this, we should mark the following parts of tk_chooseColor (a current localized version of it):

Tk color picker marked

Pay attention please to the middle line. It marks the average of R, G, B values. Here it happens to coincide with B selector, but it's not a must.

Also we should remember that the left side of color bars is shadowed dark, while the right side is shadowed light.

We are selecting for TKE editor the dark background and the light foregrounds.

We can tone the background with a warmer or cooler color, as seen on the picture below:

Choosing background

Having a dark background, we should select our foregrounds at the right (light) side.

At that we should select them so (which is most important!) that their averages to be more or less equal. For example, this way:

Choosing foreground

Again, the color averages need not to be composed as coinciding with a selector. They need not even to be of 'equal form' (B at left, G at middle, R at right). The main thing is their average that also need not to be awfully exact - it's enough to have a rough equality.

This equality means that we would get a balanced set of colors in the resulting theme. The only exception is relevant for those colors that should be about the background's side, e.g. the comments' color.

Another consideration is applied to a set of themes. Well, if you've developed a nice theme, you probably would wish to use it at the different lightings, e.g. at the cloudy morning, bright day or coal night. For this, all you need is to shift all your colors to one or another side of tk_chooseColor:

1. At the day light you would have a more contrasted version of your theme.

2. At the night light you would have a less contrasted version of your theme.

The new features of tk_chooseColor (Move all, Tone moves) would be helpful for shifting the foreground colors.

Of course, it's all for your own color preferences.

Below is the screenshot of MildDark theme for TKE editor . The editor has a smart color themer that invokes the tk_chooseColor in Linux. The Preview feature of TKE themer allows to preview and correct the developed color scheme 'on fly'.

Please don't judge my color preferences too strictly.

TKE editor

Further details:

https://aplsimple.github.io/en/tcl/tkcc