wxTheColourDatabase class in wxWindows has two methods for converting
between RGB values and named colors.
FindColour
FindName
Both return NULL if a match isn't found. These look like the methods I need,
but they don't appear to be exposed by wxPython. The colourdb.py file does
have getColourInfoList() which could be used to do some equivelant functions
for FindColour and FindName. The search is made more complex though, because
the r, g, b values are not stored as a tuple. Perhaps a lambda or list
comprehension or something could be used to make a sensible search,
otherwise it might be nice to have the list stored as a nested list:
("SNOW", (255, 250, 250)),
or dictionary
"SNOW":(255, 250, 250),
That might break some existing programs (yes?), so I lean towards adding
utility functions to colourdb.py to provide the equivelant of FindColour and
FindName, which also avoids the need for a program to create their own copy
of the colour list.
There is also wxNamedColour
wx.wxNamedColour('dark magenta')
which appears to work, except that if you pass it a non-existant named color
you get back (0, 0, 0) rather than None.
wx.wxNamedColour('bad color')
(0, 0, 0)
Other suggestions?
ka