Phoenix Logo

phoenix_title 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.


class_hierarchy Class Hierarchy

Inheritance diagram for class Brush:

method_summary Methods Summary

__init__ Default constructor.
GetColour Returns a reference to the brush colour.
GetStipple Gets a pointer to the stipple bitmap.
GetStyle Returns the brush style, one of the wx.BrushStyle values.
IsHatch Returns True if the style of the brush is any of hatched fills.
IsNonTransparent Returns True if the brush is a valid non-transparent brush.
IsOk Returns True if the brush is initialised.
IsTransparent Returns True if the brush is transparent.
MacSetTheme  
SetColour Sets the brush colour using red, green and blue values.
SetStipple Sets the stipple bitmap.
SetStyle Sets the brush style.
__nonzero__  
_copyFrom For internal use only.
__ne__ Inequality operator.
__eq__ Equality operator.

property_summary Properties Summary

Colour See GetColour and SetColour
Stipple See GetStipple and SetStipple
Style See GetStyle and SetStyle

api Class API



class wx.Brush(GDIObject)

Possible constructors:

Brush()

Brush(colour, style=BRUSHSTYLE_SOLID)

Brush(stippleBitmap)

Brush(brush)

A brush is a drawing tool for filling in areas.


Methods



__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self)

Default constructor.

The brush will be uninitialised, and wx.Brush: IsOk will return False.



__init__ (self, colour, style=BRUSHSTYLE_SOLID)

Constructs a brush from a colour object and style.

Parameters:



__init__ (self, stippleBitmap)

Constructs a stippled brush using a bitmap.

The brush style will be set to BRUSHSTYLE_STIPPLE .

Parameters:stippleBitmap (wx.Bitmap) –



__init__ (self, brush)

Copy constructor, uses reference counting.

Parameters:brush (wx.Brush) –





GetColour(self)

Returns a reference to the brush colour.

Return type: wx.Colour

See also

SetColour



GetStipple(self)

Gets a pointer to the stipple bitmap.

If the brush does not have a BRUSHSTYLE_STIPPLE style, this bitmap may be not None but uninitialised (i.e. wx.Bitmap: IsOk returns False).

Return type: wx.Bitmap

See also

SetStipple



GetStyle(self)

Returns the brush style, one of the wx.BrushStyle values.

Return type: wx.BrushStyle


IsHatch(self)

Returns True if the style of the brush is any of hatched fills.

Return type:bool

See also

GetStyle



IsNonTransparent(self)

Returns True if the brush is a valid non-transparent brush.

This method returns True if the brush object is initialized and has a non-transparent style. Notice that this should be used instead of simply testing whether GetStyle returns a style different from wx.BRUSHSTYLE_TRANSPARENT if the brush may be invalid as GetStyle would assert in this case.

Return type:bool

New in version 2.9.2..

See also

IsTransparent



IsOk(self)

Returns True if 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 True if the brush is transparent.

A transparent brush is simply a brush with wx.BRUSHSTYLE_TRANSPARENT style.

Notice that this function works even for non-initialized brushes (for which it returns False) unlike tests of the form GetStyle == wx.BRUSHSTYLE_TRANSPARENT which would assert if the brush is invalid.

Return type:bool

New in version 2.9.2..

See also

IsNonTransparent



MacSetTheme(self, macThemeBrushID)


SetColour(self, *args, **kw)

Sets the brush colour using red, green and blue values.

See also

GetColour

overload Overloaded Implementations:



SetColour (self, colour)

Parameters:colour (wx.Colour) –



SetColour (self, red, green, blue)

Parameters:
  • red (int) –
  • green (int) –
  • blue (int) –





SetStipple(self, bitmap)

Sets the stipple bitmap.

Parameters:bitmap (wx.Bitmap) – The bitmap to use for stippling.

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

wx.Bitmap



SetStyle(self, style)

Sets the brush style.

Parameters:style (BrushStyle) – One of the wx.BrushStyle values.

See also

GetStyle



__nonzero__(self)
Return type:int


_copyFrom(self, other)

For internal use only.



__ne__(self)

Inequality operator.

See Object Comparison for more info.

Parameters:brush (wx.Brush) –


__eq__(self)

Equality operator.

See Object Comparison for more info.

Parameters:brush (wx.Brush) –

Properties



Colour

See GetColour and SetColour



Stipple

See GetStipple and SetStipple



Style

See GetStyle and SetStyle