wx.BrushList

Inheritance diagram for wx.BrushList:



Description

A brush list is a list containing all brushes which have been created.

See also

wx.Brush

Derived From

Remarks

There is only one instance of this class: wx.TheBrushList. Use this object to search for a previously created brush of the desired type and create it if not already found. In some windowing systems, the brush may be a scarce resource, so it can pay to reuse old resources if possible. When an application finishes, all brushes will be deleted and their resources freed, eliminating the possibility of ‘memory leaks’. However, it is best not to rely on this automatic cleanup because it can lead to double deletion in some circumstances.

There are two mechanisms in recent versions of wxPython which make the brush list less useful than it once was. Under Windows, scarce resources are cleaned up internally if they are not being used. Also, a reference counting mechanism applied to all GDI objects means that some sharing of underlying resources is possible. You don’t have to keep track of pointers, working out when it is safe delete a brush, because the reference counting does it for you. For example, you can set a brush in a device context, and then immediately delete the brush you passed, because the brush is ‘copied’.

So you may find it easier to ignore the brush list, and instead create and copy brushes as you see fit. If your Windows resource meter suggests your application is using too many resources, you can resort to using GDI lists to share objects explicitly. The only compelling use for the brush list is for wxPython to keep track of brushes in order to clean them up on exit. It is also kept for backward compatibility with earlier versions of wxPython.

Methods Summary

Class API

Methods

__init__()
No docstrings available for this method.

FindOrCreateBrush(colour, style=wx.SOLID)

Finds a brush with the specified attributes and returns it, else creates a new brush, adds it to the brush list, and returns it.

Parameters:


Returns:

wx.Brush