JayBy 2016-05-30

Tcl/Tk is the best for me to write scripts and GUI applications, but the ttk::theme concept has a big bug. It uses his own colors without looking for the GUI environments. The 'old' Tk uses the Xresources, so the user can manipulate the Gui on this way. But it seems Ttk doesn't do that (at least on Linux). To get a uniform GUI, tk and ttk share their colors.

The nicest theme looks ugly, if it doesn't match the system environment.

Theme clam on my dark desktop: xtk::theme-Image-1

Theme gtk2: xtk::theme-Image-2

xtk::theme provides two themes: 'gtk2' and 'tk'. The color structure follows the concept of gtk and privides five color pairs (back/fore) plus a dark/light pair for each widget type. Widget types are ...

  • Standard : for labels ...
  • Form : like buttons ...
  • Input : like entries ...

The 'gtk2' theme tries to read the current gtk theme and reads it's configuration. It reads only the default style of gtk. As fallback it uses a builtin config file. So Tk reads the system/x11 colors, the theme 'tk' uses that colors.

If xfce or gnome is detected as DESKTOP_SESSION, 'gtk2' will be set as the default theme, otherwise it uses 'tk' as default.

It is recommended to change the themes with the command ::xtk::theme::ttk::init <Themes>, instead of using the ttk::style theme use <Theme> command.




package require defColor ?0.3?
package require xtk::theme ?0.2?


::xtk::theme::ttk::init <Theme>
This procedure provide the uniform look for the 'tk' and 'ttk' widgets.
You should use this procedure to change the ttk::themes, instead of 'ttk::style theme use <Theme>'.


These color arrays are structered like the gtk colors for three widget types with six back/fore color pairs, one for each state and one for light/dark.
The widget types are: Standard for labels ..., Form for buttons ..., Input for entries ...
The widget states are: Normal, Select, Active, Highlight, Disabled.