Table Of Contents

Previous topic

DataViewModelNotifier

This Page

phoenix_title DataViewRenderer

This class is used by DataViewCtrl to render the individual cells.

One instance of a renderer class is owned by a DataViewColumn. There is a number of ready-to-use renderers provided:

  • DataViewTextRenderer,
  • DataViewIconTextRenderer,
  • DataViewToggleRenderer,
  • DataViewProgressRenderer,
  • DataViewBitmapRenderer,
  • DataViewDateRenderer,
  • DataViewSpinRenderer.
  • DataViewChoiceRenderer.

Additionally, the user can write own renderers by deriving from DataViewCustomRenderer.

The DataViewCellMode and 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 Inheritance Diagram

Inheritance diagram for class DataViewRenderer

Inheritance diagram of DataViewRenderer


sub_classes Known Subclasses

DataViewBitmapRenderer, DataViewChoiceRenderer, DataViewCustomRenderer, DataViewDateRenderer, DataViewIconTextRenderer, DataViewProgressRenderer, DataViewTextRenderer, DataViewToggleRenderer


method_summary Methods Summary

__init__ Constructor.
DisableEllipsize Disable replacing parts of the item text with ellipsis.
EnableEllipsize Enable or disable replacing parts of the item text with ellipsis to make it fit the column width.
GetAlignment Returns the alignment.
GetEllipsizeMode Returns the ellipsize mode used by the renderer.
GetMode Returns the cell mode.
GetOwner Returns pointer to the owning DataViewColumn.
GetValue This methods retrieves the value from the renderer in order to transfer the value back to the data model.
GetVariantType Returns a string with the type of the Variant supported by this renderer.
SetAlignment Sets the alignment of the renderer’s content.
SetOwner Sets the owning DataViewColumn.
SetValue Set the value of the renderer (and thus its cell) to value.
Validate Before data is committed to the data model, it is passed to this method where it can be checked for validity.

api Class API



class DataViewRenderer(Object)

This class is used by DataViewCtrl to render the individual cells.

Possible constructors:

DataViewRenderer(varianttype, mode=DATAVIEW_CELL_INERT,
                 align=DVR_DEFAULT_ALIGNMENT)

Methods



__init__(self, varianttype, mode=DATAVIEW_CELL_INERT, align=DVR_DEFAULT_ALIGNMENT)

Constructor.

Parameters:
  • varianttype (string) –
  • mode (DataViewCellMode) –
  • align (int) –


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)

New 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 DataViewTextRenderer or DataViewIconTextRenderer.

By default ELLIPSIZE_MIDDLE is used.

Parameters:mode (EllipsizeMode) – Ellipsization mode, use ELLIPSIZE_NONE to disable.

New in version 2.9.1.



GetAlignment(self)

Returns the alignment.

See SetAlignment

Return type:int


GetEllipsizeMode(self)

Returns the ellipsize mode used by the renderer.

If the return value is ELLIPSIZE_NONE, the text is simply truncated if it doesn’t fit.

Return type: EllipsizeMode

See also

EnableEllipsize



GetMode(self)

Returns the cell mode.

Return type:DataViewCellMode


GetOwner(self)

Returns pointer to the owning DataViewColumn.

Return type: DataViewColumn


GetValue(self, value)

This methods retrieves the value from the renderer in order to transfer the value back to the data model.

Returns False on failure.

Parameters:value (Variant) –
Return type:bool


GetVariantType(self)

Returns a string with the type of the Variant supported by this renderer.

Return type:string


SetAlignment(self, align)

Sets the alignment of the renderer’s content.

The default value of DVR_DEFAULT_ALIGMENT indicates that the content should have the same alignment as the column header.

The method is not implemented under OS X 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) –


SetOwner(self, owner)

Sets the owning DataViewColumn.

This is usually called from within DataViewColumn.

Parameters:owner (dataview.DataViewColumn) –


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 (Variant) –
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.). Return False 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 (Variant) –
Return type:bool

Properties



Alignment

See GetAlignment and SetAlignment



EllipsizeMode

See GetEllipsizeMode



Mode

See GetMode



Owner

See GetOwner and SetOwner



VariantType

See GetVariantType