Phoenix icon indicating copy to clipboard operation
Phoenix copied to clipboard

ColourDatabase doesn't work right -- wrong colours, missing colours

Open ckp95 opened this issue 3 years ago • 1 comments
trafficstars

Operating system: Windows 10 wxPython version & source: 4.2.0 msw (phoenix) wxWidgets 3.2.0 installed via pip from pypi Python version & source: 3.8.10, installed via pyenv

Description of the problem:

Either I'm totally misunderstanding how the ColourDatabase is meant to work, or it's broken. I am going by the docs on this page, the list of RGB values given on a third-party site here, and also this source module here which seems to be where the colours are defined. Some colours work, some colours are wrong, some colours don't work at all.

import wx
import sys

app = wx.App()
print(wx.version())
print(sys.version)
cols = wx.ColourDatabase()

for colour_name in ["THISTLE", "MEDIUM VIOLET RED", "SALMON", "LIGHT CORAL"]:
    colour = cols.Find(colour_name)
    print(f"{colour_name} = {colour}, isok={colour.IsOk()}")

This gives the result:

4.2.0 msw (phoenix) wxWidgets 3.2.0
3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
THISTLE = (216, 191, 216, 255), isok=True
MEDIUM VIOLET RED = (219, 112, 147, 255), isok=True
SALMON = (111, 66, 66, 255), isok=True
LIGHT CORAL = (-1, -1, -1, 255), isok=False

THISTLE looks like it is correct: the RGB value matches both the value given here and here.

MEDIUM VIOLET RED's RGB value differs from that given in the source code, but matches that given here.

SALMON likewise differs from what is given in the source code.

LIGHT CORAL isn't even found in the database despite the docs claiming it should be there, and the source line here.

I've searched through the source code and I'm unable to find how the values shown printed above are actually arrived at. This is either a documentation problem or a bug.

ckp95 avatar Sep 12 '22 14:09 ckp95

The colors provided by wx.ColourDatabase are actually defined in the C++ code, which you can refer to here: https://github.com/wxWidgets/wxWidgets/blob/master/src/common/gdicmn.cpp#L298

wx.lib.colourdb is a separate pure-Python module that adds additional colors to the C++ ones. If you want a use a color database, I would recommend using the wx.ColourDatabase as it's likely to be better maintained.

swt2c avatar Sep 12 '22 16:09 swt2c

Closing as there doesn't seem to be a bug here.

swt2c avatar Dec 23 '22 00:12 swt2c

This issue has been mentioned on Discuss wxPython. There might be relevant details there:

https://discuss.wxpython.org/t/wx-colourdatabase/36366/3

RobinD42 avatar Feb 11 '23 20:02 RobinD42