If I can retrieve the various colors being used for the current theme,
is there a way I can change the icon image colors to match? Or some
other simpler way of achieving the same? Right now I'm using a canvas
based button where I draw the (simple) image as a workaround but this
has many many limitations.
A secondary question - how can I tell when the user changes the theme
so I can change colors in my non-native widgets appropriately?
Thanks
/Ashok
The usual way of handling this is to use icons with
transparent backgrounds. (The best way to do that
is to use PNG icons with alpha blending, and the
best way to do *that* is with Michael Kirkham's
TkPNG extension:
<URL: http://www.muonics.com/FreeStuff/TkPNG/ >
The Img extension will also work, but TkPNG is easier
to deploy.)
As for the related question of how to figure out the
theme's color scheme: at present there's not enough
consistency across platforms to answer that sensibly.
Most themes have some notion of a background color --
except on OSX, which doesn't even have *that* --
but beyond that it gets fuzzy. On Windows, there's
a collection of ~2 dozen symbolic color names assigned
to various user interface elements, accessible from
Tk as named colors like SystemButtonFace, SystemWindowFrame,
etc. Mac OSX has something similar, although the
Aqua symbolic colors aren't available directly from Tk.
KDE has a reasonably sensible mechanism for defining
color schemes -- unfortunately it's only accessible
to Qt-based applications. Color schemes under Gnome
are largely ad-hoc, defined on a theme-by-theme basis.
Tile is scheduled to adopt a system similar to the one
KDE uses. It hasn't been integrated yet, but a rough
draft is available here:
<URL: http://www.flightlab.com/~joe/repos/themebag/colorscheme.tcl >
<URL: http://www.flightlab.com/~joe/repos/themebag/palette.tcl >
>A secondary question - how can I tell when the user changes the theme
>so I can change colors in my non-native widgets appropriately?
Tile sends a <<ThemeChanged>> virtual event to every
window in the application when the theme changes (including
core widgets); you can bind to that.
--Joe English