I was doing some experiments with the following code.
import wx
import wx.lib.colourdb
app = wx.App()
print(f"wxPython version = {wx.VERSION_STRING}")
name = "DARK RED"
# wx.lib.colourdb.updateColourDB()
c = wx.Colour(name)
print(f"'{name}' = {repr(c)} [IsOk() = {c.IsOk()}]" )
colour_dict = {}
for nm, r, g, b in wx.lib.colourdb.getColourInfoList():
colour_dict[nm] = wx.Colour(r, g, b)
c = colour_dict[name]
print(f"'{name}' = {repr(c)} [IsOk() = {c.IsOk()}]" )
Running it on 4.2.5 gave the following output:
wxPython version = 4.2.5
'DARK RED' = wx.Colour(139, 0, 0, 255) [IsOk() = True]
'DARK RED' = wx.Colour(139, 0, 0, 255) [IsOk() = True]
Running it on 4.3.1 gave the following output:
wxPython version = 4.3.1
'DARK RED' = wx.Colour(-1, -1, -1, 255) [IsOk() = False]
'DARK RED' = wx.Colour(139, 0, 0, 255) [IsOk() = True]
That shows that the âDARK REDâ is defined in the wx.lib.colourdb database, but passing that string to wx.Colour() fails.
However, if I uncomment the wx.lib.colourdb.updateColourDB() line, it does succeed:
wxPython version = 4.3.1
'DARK RED' = wx.Colour(139, 0, 0, 255) [IsOk() = True]
'DARK RED' = wx.Colour(139, 0, 0, 255) [IsOk() = True]
Does 4.2.5 automatically call wx.lib.colourdb.updateColourDB() but 4.3.1 doesnât?