Drawing gradients with GraphicsContext
GraphicsContext
is another drawing utility class, similar to a DeviceContext
, which provides some higher-level or advanced functionality for drawing on screen. The GraphicsContext
is a new feature that was added back in wxPython 2.8, which can be used to access some of the platform's higher-level drawing functionality-supporting features, such as antialiasing, a floating point precision coordinate system, alpha blending, gradient brushes, and a handful of other advanced methods. In this recipe, we will make use of some of these features, most notably the gradient brush, to draw a custom control that uses gradient shading to give more depth to the control's appearance.
How to do it…
Here are the steps you need to perform:
First, we will start by deriving a class from
PyControl
to use it as a custom StaticText-like control, as follows:class PodLabel(wx.PyControl): def __init__(self, parent, label, color): super(PodLabel, self).__init__(parent...