 wx.Brush¶
  wx.Brush¶
A brush is a drawing tool for filling in areas.
It is used for painting the background of rectangles, ellipses, etc. It has a colour and a style.
On a monochrome display, wxWidgets shows all brushes as white unless the colour is really black.
Do not initialize objects on the stack before the program commences, since other required structures may not have been set up yet. Instead, define global pointers to objects and create them in wx.App.OnInit   or when required.
An application may wish to create brushes with different characteristics dynamically, and there is the consequent danger that a large number of duplicate brushes will be created. Therefore an application may wish to get a pointer to a brush by using the global list of brushes wx.TheBrushList     , and calling the member function wx.BrushList.FindOrCreateBrush .
This class uses reference counting and copy-on-write internally so that assignments between two instances of this class are very cheap. You can therefore use actual objects instead of pointers without efficiency problems. If an instance of this class is changed it will create its own data internally so that other instances, which previously shared the data using the reference counting, are not affected.
See also
 Class Hierarchy¶
 Class Hierarchy¶
 Methods Summary¶
 Methods Summary¶
| Default constructor. | |
| Returns a reference to the brush colour. | |
| Gets a pointer to the stipple bitmap. | |
| Returns the brush style, one of the wx.BrushStyle values. | |
| Returns  | |
| Returns  | |
| Returns  | |
| Returns  | |
| Sets the brush colour using red, green and blue values. | |
| Sets the stipple bitmap. | |
| Sets the brush style. | |
| For internal use only. | |
| Inequality operator. | |
| Equality operator. | 
 Properties Summary¶
 Properties Summary¶
| See  | |
 Class API¶
 Class API¶
- class wx.Brush(GDIObject)¶
- Possible constructors: - Brush() -> None Brush(colour, style=BRUSHSTYLE_SOLID) -> None Brush(stippleBitmap) -> None Brush(brush) -> None - A brush is a drawing tool for filling in areas. 
 - Methods¶- __init__(self, *args, **kw)¶
- 
__init__ (self) Default constructor. The brush will be uninitialised, and wx.Brush: IsOkwill returnFalse.- Return type:
- None 
 __init__ (self, colour, style=BRUSHSTYLE_SOLID) Constructs a brush from a colour object and style. - Parameters:
- colour (wx.Colour) – Colour object. 
- style (BrushStyle) – One of the wx.BrushStyle enumeration values. 
 
- Return type:
- None 
 __init__ (self, stippleBitmap) Constructs a stippled brush using a bitmap. The brush style will be set to BRUSHSTYLE_STIPPLE.- Parameters:
- stippleBitmap (wx.Bitmap) 
- Return type:
- None 
 __init__ (self, brush) Copy constructor, uses reference counting. - Parameters:
- brush (wx.Brush) 
- Return type:
- None 
 
 
 - GetStipple(self)¶
- Gets a pointer to the stipple bitmap. - If the brush does not have a - BRUSHSTYLE_STIPPLEstyle, this bitmap may be not- Nonebut uninitialised (i.e. wx.Bitmap:- IsOkreturns- False).- Return type:
 - See also 
 - GetStyle(self)¶
- Returns the brush style, one of the wx.BrushStyle values. - Return type:
 - See also 
 - IsHatch(self)¶
- Returns - Trueif the style of the brush is any of hatched fills.- Return type:
- bool 
 - See also 
 - IsNonTransparent(self)¶
- Returns - Trueif the brush is a valid non-transparent brush.- This method returns - Trueif the brush object is initialized and has a non-transparent style. Notice that this should be used instead of simply testing whether- GetStylereturns a style different from- wx.BRUSHSTYLE_TRANSPARENTif the brush may be invalid as- GetStylewould assert in this case.- Return type:
- bool 
 - Added in version 2.9.2.. - See also 
 - IsOk(self)¶
- Returns - Trueif the brush is initialised.- Notice that an uninitialized brush object can’t be queried for any brush properties and all calls to the accessor methods on it will result in an assert failure. - Return type:
- bool 
 
 - IsTransparent(self)¶
- Returns - Trueif the brush is transparent.- A transparent brush is simply a brush with - wx.BRUSHSTYLE_TRANSPARENTstyle.- Notice that this function works even for non-initialized brushes (for which it returns - False) unlike tests of the form- GetStyle==- wx.BRUSHSTYLE_TRANSPARENTwhich would assert if the brush is invalid.- Return type:
- bool 
 - Added in version 2.9.2.. - See also 
 - MacSetTheme(self, macThemeBrushID)¶
- Return type:
- None 
 
 - SetColour(self, *args, **kw)¶
- Sets the brush colour using red, green and blue values. - See also - SetColour (self, colour) - Parameters:
- colour (wx.Colour) 
- Return type:
- None 
 - SetColour (self, red, green, blue) - Parameters:
- red (int) 
- green (int) 
- blue (int) 
 
- Return type:
- None 
 
 - SetStipple(self, bitmap)¶
- Sets the stipple bitmap. - Parameters:
- bitmap (wx.Bitmap) – The bitmap to use for stippling. 
- Return type:
- None 
 - Note - The style will be set to - BRUSHSTYLE_STIPPLE, unless the bitmap has a mask associated to it, in which case the style will be set to- BRUSHSTYLE_STIPPLE_MASK_OPAQUE.- See also 
 - SetStyle(self, style)¶
- Sets the brush style. - Parameters:
- style (BrushStyle) – One of the wx.BrushStyle values. 
- Return type:
- None 
 - See also 
 - __bool__(self)¶
- Return type:
- bool 
 
 - __nonzero__(self)¶
- Return type:
- bool 
 
 - _copyFrom(self, other)¶
- For internal use only. - Return type:
- None 
 
 - __ne__(self, brush)¶
- Inequality operator. - See Object Comparison for more info. - Parameters:
- brush (wx.Brush) 
- Return type:
- bool 
 
 - __eq__(self, brush)¶
- Equality operator. - See Object Comparison for more info. - Parameters:
- brush (wx.Brush) 
- Return type:
- bool 
 
 
 - Properties¶- Stipple¶
- See - GetStippleand- SetStipple
 
 

