wx.dataview.DataViewRenderer¶
This class is used by wx.dataview.DataViewCtrl to render the individual cells.
One instance of a renderer class is owned by a wx.dataview.DataViewColumn. There is a number of ready-to-use renderers provided:
Additionally, the user can write their own renderers by deriving from wx.dataview.DataViewCustomRenderer.
The wx.dataview.DataViewCellMode and wx.dataview.DataViewCellRenderState flags accepted by the constructors respectively controls what actions the cell data allows and how the renderer should display its contents in a cell.
Class Hierarchy¶
Known Subclasses¶
wx.dataview.DataViewBitmapRenderer, wx.dataview.DataViewCheckIconTextRenderer, wx.dataview.DataViewChoiceRenderer, wx.dataview.DataViewCustomRenderer, wx.dataview.DataViewDateRenderer, wx.dataview.DataViewIconTextRenderer, wx.dataview.DataViewProgressRenderer, wx.dataview.DataViewTextRenderer, wx.dataview.DataViewToggleRenderer
Methods Summary¶
Constructor. |
|
Disable replacing parts of the item text with ellipsis. |
|
Enable or disable replacing parts of the item text with ellipsis to make it fit the column width. |
|
Returns the alignment. |
|
Returns the ellipsize mode used by the renderer. |
|
Returns the cell mode. |
|
Returns pointer to the owning wx.dataview.DataViewColumn. |
|
This methods retrieves the value from the renderer in order to transfer the value back to the data model. |
|
Returns a string with the type of the Variant supported by this renderer. |
|
Check if the given variant type is compatible with the type expected by this renderer. |
|
Sets the alignment of the renderer’s content. |
|
Sets the owning wx.dataview.DataViewColumn. |
|
Set the value of the renderer (and thus its cell) to value. |
|
Set the transformer object to be used to customize values before they are rendered. |
|
Before data is committed to the data model, it is passed to this method where it can be checked for validity. |
Properties Summary¶
See |
|
See |
|
See |
|
See |
|
See |
|
See |
Class API¶
- class wx.dataview.DataViewRenderer(Object)¶
Possible constructors:
DataViewRenderer(varianttype, mode=DATAVIEW_CELL_INERT, align=DVR_DEFAULT_ALIGNMENT) -> None
This class is used by DataViewCtrl to render the individual cells.
Methods¶
- __init__(self, varianttype, mode=DATAVIEW_CELL_INERT, align=DVR_DEFAULT_ALIGNMENT)¶
Constructor.
The varianttype parameter is the main type of Variant objects supported by this renderer, i.e. those that can be passed to its
SetValue
, e.g. “string” for wx.dataview.DataViewTextRenderer. The value of this parameter is returned byGetVariantType
.When deriving a custom renderer, either an existing variant type or a new custom one can be used, see Variant documentation for more details.
- Parameters:
varianttype (string)
mode (DataViewCellMode)
align (int)
- Return type:
None
- CancelEditing(self)¶
- Return type:
None
- CreateEditorCtrl(self, parent, labelRect, value)¶
- DisableEllipsize(self)¶
Disable replacing parts of the item text with ellipsis.
If ellipsizing is disabled, the string will be truncated if it doesn’t fit.
This is the same as:
EnableEllipsize(wx.ELLIPSIZE_NONE)
- Return type:
None
Added in version 2.9.1.
- EnableEllipsize(self, mode=ELLIPSIZE_MIDDLE)¶
Enable or disable replacing parts of the item text with ellipsis to make it fit the column width.
This method only makes sense for the renderers working with text, such as wx.dataview.DataViewTextRenderer or wx.dataview.DataViewIconTextRenderer.
By default
wx.ELLIPSIZE_MIDDLE
is used.- Parameters:
mode (EllipsizeMode) – Ellipsization mode, use
wx.ELLIPSIZE_NONE
to disable.- Return type:
None
Added in version 2.9.1.
- FinishEditing(self)¶
- Return type:
bool
- GetAlignment(self)¶
Returns the alignment.
See
SetAlignment
- Return type:
int
- GetEditorCtrl(self)¶
- Return type:
Window
- GetEllipsizeMode(self)¶
Returns the ellipsize mode used by the renderer.
If the return value is
wx.ELLIPSIZE_NONE
, the text is simply truncated if it doesn’t fit.- Return type:
See also
- GetMode(self)¶
Returns the cell mode.
- Return type:
- GetOwner(self)¶
Returns pointer to the owning wx.dataview.DataViewColumn.
- Return type:
- GetValue(self)¶
This methods retrieves the value from the renderer in order to transfer the value back to the data model.
Returns
False
on failure.- Return type:
DVCVariant
- GetVariantType(self)¶
Returns a string with the type of the Variant supported by this renderer.
Note that a renderer may support more than one variant type, in which case it needs to override
IsCompatibleVariantType
to returnTrue
for all types it supports. But by default only the type returned by this function is supported.- Return type:
str
- GetView(self)¶
- Return type:
- HasEditorCtrl(self)¶
- Return type:
bool
- IsCompatibleVariantType(self, variantType)¶
Check if the given variant type is compatible with the type expected by this renderer.
The base class implementation just compares variantType with the value returned by
GetVariantType
, but this function can be overridden to accept other types that can be converted to the type needed by the renderer.- Parameters:
variantType (string)
- Return type:
bool
Added in version 4.1/wxWidgets-3.1.7.
- SetAlignment(self, align)¶
Sets the alignment of the renderer’s content.
The default value of
DVR_DEFAULT_ALIGNMENT
indicates that the content should have the same alignment as the column header.The method is not implemented under macOS and the renderer always aligns its contents as the column header on that platform. The other platforms support both vertical and horizontal alignment.
- Parameters:
align (int)
- Return type:
None
- SetOwner(self, owner)¶
Sets the owning wx.dataview.DataViewColumn.
This is usually called from within wx.dataview.DataViewColumn.
- Parameters:
owner (wx.dataview.DataViewColumn)
- Return type:
None
- SetValue(self, value)¶
Set the value of the renderer (and thus its cell) to value.
The internal code will then render this cell with this data.
- Parameters:
value (
DVCVariant
) – A valid, i.e. non-null, value to be shown.- Return type:
bool
- SetValueAdjuster(self, transformer)¶
Set the transformer object to be used to customize values before they are rendered.
Can be used to change the value if it is shown on a highlighted row (i.e. in selection) which typically has dark background. It is useful in combination with wx.dataview.DataViewTextRenderer with markup and can be used e.g. to remove background color attributes inside selection, as a lightweight alternative to implementing an entire wx.dataview.DataViewCustomRenderer specialization.
transformer can be
None
to reset any transformer currently being used.Takes ownership of transformer.
- Parameters:
transformer (wx.dataview.DataViewValueAdjuster)
- Return type:
None
Added in version 4.1/wxWidgets-3.1.1.
See also
- StartEditing(self, item, labelRect)¶
- Parameters:
item (wx.dataview.DataViewItem)
labelRect (wx.Rect)
- Return type:
bool
- Validate(self, value)¶
Before data is committed to the data model, it is passed to this method where it can be checked for validity.
This can also be used for checking a valid range or limiting the user input in a certain aspect (e.g. max number of characters or only alphanumeric input,
ASCII
only etc.). ReturnFalse
if the value is not valid.Please note that due to implementation limitations, this validation is done after the editing control already is destroyed and the editing process finished.
- Parameters:
value (DVCVariant)
- Return type:
bool
Properties¶
- Alignment¶
See
GetAlignment
andSetAlignment
- EditorCtrl¶
See
GetEditorCtrl
- EllipsizeMode¶
See
GetEllipsizeMode
- VariantType¶
See
GetVariantType