Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to make icon image colors match Tile themes?

4 views
Skip to first unread message

pal...@yahoo.com

unread,
Feb 4, 2006, 7:07:05 AM2/4/06
to
I have buttons containing images in a Tile-based Windows application.
The images are fairly simple with just a couple of colors. What I want
to be able to do is to have those colors match whatever theme is in
use. So if the user changes the Windows color scheme from "Default
blue" to "Steel" I want my icon colors to change accordingly (just as
the Tile widgets do). How does one do this? I don't want to have
multiple images particularly since the number of possible themes/color
schemes is unlimited.

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

Joe English

unread,
Feb 4, 2006, 5:53:14 PM2/4/06
to
Ashok wrote:
>
>I have buttons containing images in a Tile-based Windows application.
>The images are fairly simple with just a couple of colors. What I want
>to be able to do is to have those colors match whatever theme is in
>use. So if the user changes the Windows color scheme from "Default
>blue" to "Steel" I want my icon colors to change accordingly (just as
>the Tile widgets do). How does one do this? I don't want to have
>multiple images particularly since the number of possible themes/color
>schemes is unlimited.

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

0 new messages