On Thu, Mar 02, 2000 at 10:47:06AM +0100, Javi Roman wrote:
> I have:
>
> ...
> style = self.window.get_style ().copy ()
> style.bg[STATE_NORMAL] = style.black
> self.window.set_style (style)
> ...
>
> This works correctly, but i want a red background color, and i try:
>
> ...
> style.bg[STATE_NORMAL] = style.red
> ...
>
> This fail. I think that i don't understand very well. Can anybody help
> me?
>
>
Side issue:
Suggestion to James: make the GDK colormap allocation function accept
floating point values from 0 to 1 as well as 16-bit integers. Or does
it do this already?
The "bg" element is an "array" of five GDKcolors, which have to be
allocated. (style.black is a provided constant, but there is no
style.red.) GDKcolors, in turn, are created per X-window (blargh)
from three 16-bit RGB values.
# set the background style
red = (1,0,0)
for i in range(5):
style.bg[i] = _alloc_color (o.window, red)
# Allocate a GDKcolor from RGB values expressed as numbers
# from 0 to 1.0
def _alloc_color (widget, RGB):
RGB48 = map (lambda f: f * ((1<<16) - 1), RGB)
return apply (widget.get_colormap().alloc, RGB48)
Suggestion to James: provide a variant of alloc() which will accept
floating point values in the interval [0, 1.0] directly.
--
Randolph
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]