calculate a colour gradient

Grégoire Dooms dooms at
Thu Jun 17 21:22:42 CEST 2004

Mark Light wrote:
> Hi,
>    I have a tk.scale bar for which I want the background to change from
> blue to red as I slide along it. The mechanics of this I can do, but
> the colour gradient I have is very crude - basically the amount of R in
> RGB just increases whilst the G and B are fixed values. Whilst this is
> not really a python question does anybody have any suggestions about
> calculating the RGB values for a smooth colour gradient?

Have a look at the HSV color space and HSV -> RGB conversion:

Then linearly adjust the H while you slide the bar.

Grégoire Dooms

More information about the Python-list mailing list