Colors
Use color words
Many widgets have methods that allow you to set colors. For example, almost all controls have a SetBackgroundColor method. You can pass two kinds of values to such methods:
1. A "traditional" (red, green, blue) tuple. A regular Python tuple suffices; for example, (0, 0, 0) is black, and (255, 0, 0) is red.
2. A color name known in the color database. (To get the full list of color names, see wax/colordb.py.) This is a string. Case doesn't matter, so obj.SetBackgroundColor('red') and obj.SetBackgroundColor('RED') are the same.
# colors-1.py from wax import * COLORS = ['red', 'yellow', 'BLUE', 'White', 'peachpuff', (0, 0, 0), # black (0x7F, 0x7F, 0x7F), # grey ] class MainFrame(VerticalFrame): def Body(self): # create a number of panels in various colors for color in COLORS: p = Panel(self) p.BackgroundColor = color p.Size = (400, 20) self.AddComponent(p) self.Pack() app = Application(MainFrame, title='colors-1') app.Run()
Method naming
Where wxPython traditionally uses the spelling "colour" in its method names, Wax offers alternatives using "color". So for most widgets, both SetBackgroundColor and SetBackgroundColour (etc) are available. Only the "color" versions allow named colors, though.
Open issues
There is a proposal to accept strings like "#FF007F" as color values as well.