Recreating native controls with RendererNative
The RendererNative
class is a drawing class that encapsulates and exposes routines for drawing parts of the native system's UI components. It provides high-level drawing functions that allow you to draw items such as a Button
or CheckBox
control in a DeviceContext without needing to know any of the details of how it is done. This is a powerful feature that can allow you to create your own custom widgets that still maintain a native look. In this recipe, we will recreate the CheckBox
control to add support to align the label below the CheckBox
control.
How to do it…
Perform the following:
First, we will start with the constructor for our custom
CheckBox
control:class CustomCheckBox(wx.PyControl): def __init__(self, parent, label, style=0): style |= wx.NO_BORDER super(CustomCheckBox, self).__init__(parent, style=style) self.Label = label self._value = False self...