What color names are predefined

The following color names are guaranteed to be recognized by wxPython:



blue blue violet


cadet blue

coral cornflower blue


dark gray

dark green dark olive green

dark orchid

dark slate blue

dark slate gray dark turquoise

dim gray


forest green gold



green green yellow

indian red


light blue light gray

light steel blue

lime green

magenta maroon

medium aquamarine

medium blue

medium forest green medium goldenrod

medium orchid

medium sea green

medium slate blue medium spring green

medium turquoise

medium violet red

midnight blue navy


orange red

orchid pale green



purple red


sea green

sienna sky blue

slate blue spring green turquoise white steel blue tan thistle violet violet red wheat yellow yellow green

An additional set of color names and values can be loaded into the in-memory color database using the updateColourDB function located in the wx.lib.colourdb module.

■ In wxPython, you can easily perform common graphics operations including image manipulation and drawing onto the screen. Images are managed via the class wx.lmage, which handles platform-independent image tools, such as loading from common image file formats, and the class wx.Bitmap, which handles platform-dependent tasks such as drawing the image to the screen. Predefined image handlers exist for the most popular file formats. Once you have a wx.lmage instance, you can do a variety of useful filtering operations on the data. You can define a transparent mask color, which causes a specific color in the image to be rendered as though it was transparent, allowing for chroma-key effects. You can also define a series of alpha values to make the image partially transparent on a pixel-by-pixel basis.

■ A bitmap can be created from a bitmap file, or it can take in a wx.lmage object and convert it to a bitmap. The only advantage of having your image in a wx.Bitmap instance is that wxPython needs an instance of wx.Bitmap in order to be able to draw your image to the screen.

■ You can create your own cursor or use one of about two dozen stock cursors, including the most commonly used arrows and wait cursers, as well as some more obscure ones. You can also create your own cursor from a wx.Image instance.

■ Actual drawing to the screen or to any of a number of other virtual devices is managed through the device context class wx.DC, which is an abstract class defining a common API for drawing. Various subclasses of wx.DC allow you to draw to the screen, directly to memory or to a file, or to a printer. Device contexts should only be created locally in your program, and should not be stored globally. When drawing to the screen, the type of device context you use depends on whether or not you are drawing within an evt_paint handler. There also are separate device contexts which allow you

Was this article helpful?

0 -1

Post a comment