How do I manage the background drawing brush

Any kind of fill operation, including flood fill or the fill of items created using the draw functions, is managed using the device context's current brush, which is an instance of wx.Brush. You can get the current brush using GetBrush(), and set one with SetBrush(brush). Calling the DC method Clear() redraws the entire device context using the current background brush.

The brush instances are a bit simpler than the pen. Here is the constructor for wx.Brush.

wx.Brush(colour, style=wx.SOLID)

The colour is, of course, the color used by the brush. As usual, it can be a wx.Colour instance, or an RGB-tuple, or a string. The style governs how the brush fills space, and can be one of the following, all of which have the same meaning as they do for wx.Pen.



The color and style can be manipulated via getter and setter—GetColour(), Set-Colour(colour), GetStyle(), SetStyle(). The only other thing you can do with a brush is set the stipple pattern with SetStipple(bitmap). If you create a stipple for the brush, then the style is also set to wx.STIPPLE for you. You can retrieve the stipple using GetStipple().

Was this article helpful?

0 0

Post a comment