.. wxPython Phoenix documentation This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. Copyright: (c) 2011-2017 by Total Control Software License: wxWindows License .. include:: headings.inc .. _wx.dataview.DataViewCtrl: ========================================================================================================================================== |phoenix_title| **wx.dataview.DataViewCtrl** ========================================================================================================================================== :ref:`wx.dataview.DataViewCtrl` is a control to display data either in a tree like fashion or in a tabular form or both. If you only need to display a simple tree structure with an API more like the older :ref:`wx.TreeCtrl` class, then the specialized :ref:`wx.dataview.DataViewTreeCtrl` can be used. Likewise, if you only want to display simple table structure you can use the specialized :ref:`wx.dataview.DataViewListCtrl` class. Both :ref:`wx.dataview.DataViewTreeCtrl` and :ref:`wx.dataview.DataViewListCtrl` can be used without defining your own :ref:`wx.dataview.DataViewModel`. A :ref:`wx.dataview.DataViewItem` is used to represent a (visible) item in the control. Unlike :ref:`wx.ListCtrl`, :ref:`wx.dataview.DataViewCtrl` doesn't get its data from the user through virtual functions or by setting it directly. Instead you need to write your own :ref:`wx.dataview.DataViewModel` and associate it with this control. Then you need to add a number of :ref:`wx.dataview.DataViewColumn` to this control to define what each column shall display. Each :ref:`wx.dataview.DataViewColumn` in turn owns 1 instance of a :ref:`wx.dataview.DataViewRenderer` to render its cells. A number of standard renderers for rendering text, dates, images, toggle, a progress bar etc. are provided. Additionally, the user can write custom renderers deriving from :ref:`wx.dataview.DataViewCustomRenderer` for displaying anything. All data transfer from the control to the model and the user code is done through `Variant` which can be extended to support more data formats as necessary. Accordingly, all type information uses the strings returned from :meth:`Variant.GetType` . .. _DataViewCtrl-styles: |styles| Window Styles ================================ This class supports the following styles: - ``wx.dataview.DV_SINGLE``: Single selection mode. This is the default. - ``wx.dataview.DV_MULTIPLE``: Multiple selection mode. - ``wx.dataview.DV_ROW_LINES``: Use alternating colours for rows if supported by platform and theme. Currently only supported by the native GTK and OS X implementations but not by the generic one. - ``wx.dataview.DV_HORIZ_RULES``: Display the separator lines between rows. - ``wx.dataview.DV_VERT_RULES``: Display the separator lines between columns. - ``wx.dataview.DV_VARIABLE_LINE_HEIGHT``: Allow variable line heights. This can be inefficient when displaying large number of items. - ``wx.dataview.DV_NO_HEADER``: Do not show column headers (which are shown by default). .. _DataViewCtrl-events: |events| Events Emitted by this Class ===================================== Handlers bound for the following event types will receive a :ref:`wx.dataview.DataViewEvent` parameter. - EVT_DATAVIEW_SELECTION_CHANGED: Process a ``wxEVT_DATAVIEW_SELECTION_CHANGED`` event. - EVT_DATAVIEW_ITEM_ACTIVATED: Process a ``wxEVT_DATAVIEW_ITEM_ACTIVATED`` event. This event is triggered by double clicking an item or pressing some special key (usually "Enter") when it is focused. - EVT_DATAVIEW_ITEM_START_EDITING: Process a ``wxEVT_DATAVIEW_ITEM_START_EDITING`` event. This event can be vetoed in order to prevent editing on an item by item basis. - EVT_DATAVIEW_ITEM_EDITING_STARTED: Process a ``wxEVT_DATAVIEW_ITEM_EDITING_STARTED`` event. - EVT_DATAVIEW_ITEM_EDITING_DONE: Process a ``wxEVT_DATAVIEW_ITEM_EDITING_DONE`` event. - EVT_DATAVIEW_ITEM_COLLAPSING: Process a ``wxEVT_DATAVIEW_ITEM_COLLAPSING`` event. - EVT_DATAVIEW_ITEM_COLLAPSED: Process a ``wxEVT_DATAVIEW_ITEM_COLLAPSED`` event. - EVT_DATAVIEW_ITEM_EXPANDING: Process a ``wxEVT_DATAVIEW_ITEM_EXPANDING`` event. - EVT_DATAVIEW_ITEM_EXPANDED: Process a ``wxEVT_DATAVIEW_ITEM_EXPANDED`` event. - EVT_DATAVIEW_ITEM_VALUE_CHANGED: Process a ``wxEVT_DATAVIEW_ITEM_VALUE_CHANGED`` event. - EVT_DATAVIEW_ITEM_CONTEXT_MENU: Process a ``wxEVT_DATAVIEW_ITEM_CONTEXT_MENU`` event generated when the user right clicks inside the control. Notice that this menu is generated even if the click didn't occur on any valid item, in this case :meth:`wx.dataview.DataViewEvent.GetItem` simply returns an invalid item. - EVT_DATAVIEW_COLUMN_HEADER_CLICK: Process a ``wxEVT_DATAVIEW_COLUMN_HEADER_CLICK`` event. - EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK: Process a ``wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK`` event. Notice that currently this event is not generated in the native OS X versions of the control. - EVT_DATAVIEW_COLUMN_SORTED: Process a ``wxEVT_DATAVIEW_COLUMN_SORTED`` event. - EVT_DATAVIEW_COLUMN_REORDERED: Process a ``wxEVT_DATAVIEW_COLUMN_REORDERED`` event. - EVT_DATAVIEW_ITEM_BEGIN_DRAG: Process a ``wxEVT_DATAVIEW_ITEM_BEGIN_DRAG`` event. - EVT_DATAVIEW_ITEM_DROP_POSSIBLE: Process a ``wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE`` event. - EVT_DATAVIEW_ITEM_DROP: Process a ``wxEVT_DATAVIEW_ITEM_DROP`` event. Notice that this control doesn't allow to process generic mouse events such as ``wxEVT_LEFT_DOWN`` in all ports (notably it doesn't work in wxGTK). If you need to handle any mouse events not covered by the ones above, consider using a custom renderer for the cells that must handle them. | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class DataViewCtrl:

| |appearance| Control Appearance =============================== | .. figure:: _static/images/widgets/fullsize/wxmsw/wx.dataview.dataviewctrl.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: _static/images/widgets/fullsize/wxmac/wx.dataview.dataviewctrl.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: _static/images/widgets/fullsize/wxgtk/wx.dataview.dataviewctrl.png :alt: wxGTK :figclass: floatcenter **wxGTK** | |sub_classes| Known Subclasses ============================== :ref:`wx.dataview.DataViewListCtrl`, :ref:`wx.dataview.DataViewTreeCtrl` | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.dataview.DataViewCtrl.__init__` Default Constructor. :meth:`~wx.dataview.DataViewCtrl.AppendBitmapColumn` Appends a column for rendering a bitmap. :meth:`~wx.dataview.DataViewCtrl.AppendColumn` Appends a :ref:`wx.dataview.DataViewColumn` to the control. :meth:`~wx.dataview.DataViewCtrl.AppendDateColumn` Appends a column for rendering a date. :meth:`~wx.dataview.DataViewCtrl.AppendIconTextColumn` Appends a column for rendering text with an icon. :meth:`~wx.dataview.DataViewCtrl.AppendProgressColumn` Appends a column for rendering a progress indicator. :meth:`~wx.dataview.DataViewCtrl.AppendTextColumn` Appends a column for rendering text. :meth:`~wx.dataview.DataViewCtrl.AppendToggleColumn` Appends a column for rendering a toggle. :meth:`~wx.dataview.DataViewCtrl._AssociateModel` Associates a :ref:`wx.dataview.DataViewModel` with the control. :meth:`~wx.dataview.DataViewCtrl.AssociateModel` Associates a :class:`DataViewModel` with the control. :meth:`~wx.dataview.DataViewCtrl.ClearColumns` Removes all columns. :meth:`~wx.dataview.DataViewCtrl.Collapse` Collapses the item. :meth:`~wx.dataview.DataViewCtrl.Create` Create the control. :meth:`~wx.dataview.DataViewCtrl.DeleteColumn` Deletes given column. :meth:`~wx.dataview.DataViewCtrl.EditItem` Programmatically starts editing given cell of `item`. :meth:`~wx.dataview.DataViewCtrl.EnableDragSource` Enable drag operations using the given `format`. :meth:`~wx.dataview.DataViewCtrl.EnableDropTarget` Enable drop operations using the given `format`. :meth:`~wx.dataview.DataViewCtrl.EnsureVisible` Call this to ensure that the given item is visible. :meth:`~wx.dataview.DataViewCtrl.Expand` Expands the item. :meth:`~wx.dataview.DataViewCtrl.ExpandAncestors` Expands all ancestors of the `item`. :meth:`~wx.dataview.DataViewCtrl.GetColumn` Returns pointer to the column. :meth:`~wx.dataview.DataViewCtrl.GetColumnCount` Returns the number of columns. :meth:`~wx.dataview.DataViewCtrl.GetColumnPosition` Returns the position of the column or -1 if not found in the control. :meth:`~wx.dataview.DataViewCtrl.GetColumns` Returns a list of column objects. :meth:`~wx.dataview.DataViewCtrl.GetCurrentColumn` Returns the column that currently has focus. :meth:`~wx.dataview.DataViewCtrl.GetCurrentItem` Returns the currently focused item. :meth:`~wx.dataview.DataViewCtrl.GetExpanderColumn` Returns column containing the expanders. :meth:`~wx.dataview.DataViewCtrl.GetIndent` Returns indentation. :meth:`~wx.dataview.DataViewCtrl.GetItemRect` Returns item rectangle. :meth:`~wx.dataview.DataViewCtrl.GetModel` Returns pointer to the data model associated with the control (if any). :meth:`~wx.dataview.DataViewCtrl.GetSelectedItemsCount` Returns the number of currently selected items. :meth:`~wx.dataview.DataViewCtrl.GetSelection` Returns first selected item or an invalid item if none is selected. :meth:`~wx.dataview.DataViewCtrl.GetSelections` Returns a list of the currently selected items. :meth:`~wx.dataview.DataViewCtrl.GetSortingColumn` Returns the :ref:`wx.dataview.DataViewColumn` currently responsible for sorting or ``None`` if none has been selected. :meth:`~wx.dataview.DataViewCtrl.HasSelection` Returns ``True`` if any items are currently selected. :meth:`~wx.dataview.DataViewCtrl.HitTest` HitTest(point) . (item, col) :meth:`~wx.dataview.DataViewCtrl.InsertColumn` Inserts a :ref:`wx.dataview.DataViewColumn` to the control. :meth:`~wx.dataview.DataViewCtrl.IsExpanded` Return ``True`` if the item is expanded. :meth:`~wx.dataview.DataViewCtrl.IsSelected` Return ``True`` if the item is selected. :meth:`~wx.dataview.DataViewCtrl.PrependBitmapColumn` Prepends a column for rendering a bitmap. :meth:`~wx.dataview.DataViewCtrl.PrependColumn` Prepends a :ref:`wx.dataview.DataViewColumn` to the control. :meth:`~wx.dataview.DataViewCtrl.PrependDateColumn` Prepends a column for rendering a date. :meth:`~wx.dataview.DataViewCtrl.PrependIconTextColumn` Prepends a column for rendering text with an icon. :meth:`~wx.dataview.DataViewCtrl.PrependProgressColumn` Prepends a column for rendering a progress indicator. :meth:`~wx.dataview.DataViewCtrl.PrependTextColumn` Prepends a column for rendering text. :meth:`~wx.dataview.DataViewCtrl.PrependToggleColumn` Prepends a column for rendering a toggle. :meth:`~wx.dataview.DataViewCtrl.Select` Select the given item. :meth:`~wx.dataview.DataViewCtrl.SelectAll` Select all items. :meth:`~wx.dataview.DataViewCtrl.SetCurrentItem` Changes the currently focused item. :meth:`~wx.dataview.DataViewCtrl.SetExpanderColumn` Set which column shall contain the tree-like expanders. :meth:`~wx.dataview.DataViewCtrl.SetIndent` Sets the indentation. :meth:`~wx.dataview.DataViewCtrl.SetRowHeight` Sets the row height. :meth:`~wx.dataview.DataViewCtrl.SetSelections` Sets the selection to the array of DataViewItems. :meth:`~wx.dataview.DataViewCtrl.Unselect` Unselect the given item. :meth:`~wx.dataview.DataViewCtrl.UnselectAll` Unselect all item. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~wx.dataview.DataViewCtrl.ColumnCount` See :meth:`~wx.dataview.DataViewCtrl.GetColumnCount` :attr:`~wx.dataview.DataViewCtrl.Columns` See :meth:`~wx.dataview.DataViewCtrl.GetColumns` :attr:`~wx.dataview.DataViewCtrl.CurrentColumn` See :meth:`~wx.dataview.DataViewCtrl.GetCurrentColumn` :attr:`~wx.dataview.DataViewCtrl.CurrentItem` See :meth:`~wx.dataview.DataViewCtrl.GetCurrentItem` and :meth:`~wx.dataview.DataViewCtrl.SetCurrentItem` :attr:`~wx.dataview.DataViewCtrl.ExpanderColumn` See :meth:`~wx.dataview.DataViewCtrl.GetExpanderColumn` and :meth:`~wx.dataview.DataViewCtrl.SetExpanderColumn` :attr:`~wx.dataview.DataViewCtrl.Indent` See :meth:`~wx.dataview.DataViewCtrl.GetIndent` and :meth:`~wx.dataview.DataViewCtrl.SetIndent` :attr:`~wx.dataview.DataViewCtrl.Model` See :meth:`~wx.dataview.DataViewCtrl.GetModel` :attr:`~wx.dataview.DataViewCtrl.SelectedItemsCount` See :meth:`~wx.dataview.DataViewCtrl.GetSelectedItemsCount` :attr:`~wx.dataview.DataViewCtrl.Selection` See :meth:`~wx.dataview.DataViewCtrl.GetSelection` :attr:`~wx.dataview.DataViewCtrl.Selections` See :meth:`~wx.dataview.DataViewCtrl.GetSelections` and :meth:`~wx.dataview.DataViewCtrl.SetSelections` :attr:`~wx.dataview.DataViewCtrl.SortingColumn` See :meth:`~wx.dataview.DataViewCtrl.GetSortingColumn` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: wx.dataview.DataViewCtrl(Control) **Possible constructors**:: DataViewCtrl() DataViewCtrl(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=DataViewCtrlNameStr) DataViewCtrl is a control to display data either in a tree like fashion or in a tabular form or both. .. method:: __init__(self, *args, **kw) |overload| Overloaded Implementations: **~~~** **__init__** `(self)` Default Constructor. **~~~** **__init__** `(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=DataViewCtrlNameStr)` Constructor. Calls :meth:`Create` . :param `parent`: :type `parent`: wx.Window :param `id`: :type `id`: wx.WindowID :param `pos`: :type `pos`: wx.Point :param `size`: :type `size`: wx.Size :param `style`: :type `style`: long :param `validator`: :type `validator`: wx.Validator :param `name`: :type `name`: string **~~~** .. method:: AppendBitmapColumn(self, *args, **kw) Appends a column for rendering a bitmap. Returns the :ref:`wx.dataview.DataViewColumn` created in the function or ``None`` on failure. |overload| Overloaded Implementations: **~~~** **AppendBitmapColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=-1, align=ALIGN_CENTER, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: string :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** **AppendBitmapColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=-1, align=ALIGN_CENTER, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: wx.Bitmap :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** .. method:: AppendColumn(self, col) Appends a :ref:`wx.dataview.DataViewColumn` to the control. Returns ``True`` on success. Note that there is a number of short cut methods which implicitly create a :ref:`wx.dataview.DataViewColumn` and a :ref:`wx.dataview.DataViewRenderer` for it (see below). :param `col`: :type `col`: wx.dataview.DataViewColumn :rtype: `bool` .. method:: AppendDateColumn(self, *args, **kw) Appends a column for rendering a date. Returns the :ref:`wx.dataview.DataViewColumn` created in the function or ``None`` on failure. .. note:: The `align` parameter is applied to both the column header and the column renderer. |overload| Overloaded Implementations: **~~~** **AppendDateColumn** `(self, label, model_column, mode=DATAVIEW_CELL_ACTIVATABLE, width=-1, align=ALIGN_NOT, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: string :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** **AppendDateColumn** `(self, label, model_column, mode=DATAVIEW_CELL_ACTIVATABLE, width=-1, align=ALIGN_NOT, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: wx.Bitmap :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** .. method:: AppendIconTextColumn(self, *args, **kw) Appends a column for rendering text with an icon. Returns the :ref:`wx.dataview.DataViewColumn` created in the function or ``None`` on failure. This method uses the :ref:`wx.dataview.DataViewIconTextRenderer` class. .. note:: The `align` parameter is applied to both the column header and the column renderer. |overload| Overloaded Implementations: **~~~** **AppendIconTextColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=-1, align=ALIGN_NOT, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: string :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** **AppendIconTextColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=-1, align=ALIGN_NOT, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: wx.Bitmap :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** .. method:: AppendProgressColumn(self, *args, **kw) Appends a column for rendering a progress indicator. Returns the :ref:`wx.dataview.DataViewColumn` created in the function or ``None`` on failure. .. note:: The `align` parameter is applied to both the column header and the column renderer. |overload| Overloaded Implementations: **~~~** **AppendProgressColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=80, align=ALIGN_CENTER, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: string :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** **AppendProgressColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=80, align=ALIGN_CENTER, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: wx.Bitmap :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** .. method:: AppendTextColumn(self, *args, **kw) Appends a column for rendering text. Returns the :ref:`wx.dataview.DataViewColumn` created in the function or ``None`` on failure. .. note:: The `align` parameter is applied to both the column header and the column renderer. |overload| Overloaded Implementations: **~~~** **AppendTextColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=-1, align=ALIGN_NOT, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: string :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** **AppendTextColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=-1, align=ALIGN_NOT, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: wx.Bitmap :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** .. method:: AppendToggleColumn(self, *args, **kw) Appends a column for rendering a toggle. Returns the :ref:`wx.dataview.DataViewColumn` created in the function or ``None`` on failure. .. note:: The `align` parameter is applied to both the column header and the column renderer. |overload| Overloaded Implementations: **~~~** **AppendToggleColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=30, align=ALIGN_CENTER, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: string :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** **AppendToggleColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=30, align=ALIGN_CENTER, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: wx.Bitmap :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** .. method:: _AssociateModel(self, model) Associates a :ref:`wx.dataview.DataViewModel` with the control. This increases the reference count of the model by 1. :param `model`: :type `model`: wx.dataview.DataViewModel :rtype: `bool` .. method:: AssociateModel(self, model) Associates a :class:`DataViewModel` with the control. Ownership of the model object is passed to C++, however it is reference counted so it can be shared with other views. .. method:: ClearColumns(self) Removes all columns. :rtype: `bool` .. method:: Collapse(self, item) Collapses the item. :param `item`: :type `item`: wx.dataview.DataViewItem .. method:: Create(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=DataViewCtrlNameStr) Create the control. Useful for two step creation. :param `parent`: :type `parent`: wx.Window :param `id`: :type `id`: wx.WindowID :param `pos`: :type `pos`: wx.Point :param `size`: :type `size`: wx.Size :param `style`: :type `style`: long :param `validator`: :type `validator`: wx.Validator :param `name`: :type `name`: string :rtype: `bool` .. method:: DeleteColumn(self, column) Deletes given column. :param `column`: :type `column`: wx.dataview.DataViewColumn :rtype: `bool` .. method:: EditItem(self, item, column) Programmatically starts editing given cell of `item`. Doesn't do anything if the item or this column is not editable. :param `item`: :type `item`: wx.dataview.DataViewItem :param `column`: :type `column`: wx.dataview.DataViewColumn .. versionadded:: 2.9.4 .. note:: Currently not implemented in OSX/Carbon. .. method:: EnableDragSource(self, format) Enable drag operations using the given `format`. :param `format`: :type `format`: wx.DataFormat :rtype: `bool` .. method:: EnableDropTarget(self, format) Enable drop operations using the given `format`. :param `format`: :type `format`: wx.DataFormat :rtype: `bool` .. method:: EnsureVisible(self, item, column=None) Call this to ensure that the given item is visible. :param `item`: :type `item`: wx.dataview.DataViewItem :param `column`: :type `column`: wx.dataview.DataViewColumn .. method:: Expand(self, item) Expands the item. :param `item`: :type `item`: wx.dataview.DataViewItem .. method:: ExpandAncestors(self, item) Expands all ancestors of the `item`. This method also ensures that the item itself as well as all ancestor items have been read from the model by the control. :param `item`: :type `item`: wx.dataview.DataViewItem .. method:: GetColumn(self, pos) Returns pointer to the column. `pos` refers to the position in the control which may change after reordering columns by the user. :param `pos`: :type `pos`: int :rtype: :ref:`wx.dataview.DataViewColumn` .. method:: GetColumnCount(self) Returns the number of columns. :rtype: `int` .. method:: GetColumnPosition(self, column) Returns the position of the column or -1 if not found in the control. :param `column`: :type `column`: wx.dataview.DataViewColumn :rtype: `int` .. method:: GetColumns(self) Returns a list of column objects. .. method:: GetCurrentColumn(self) Returns the column that currently has focus. If the focus is set to individual cell within the currently focused item (as opposed to being on the item as a whole), then this is the column that the focus is on. Returns ``None`` if no column currently has focus. :rtype: :ref:`wx.dataview.DataViewColumn` .. versionadded:: 2.9.4 .. seealso:: :meth:`GetCurrentItem` .. method:: GetCurrentItem(self) Returns the currently focused item. This is the item that the keyboard commands apply to. It may be invalid if there is no focus currently. This method is mostly useful for the controls with ``DV_MULTIPLE`` style as in the case of single selection it returns the same thing as :meth:`GetSelection` . Notice that under all platforms except Mac OS X the currently focused item may be selected or not but under OS X the current item is always selected. :rtype: :ref:`wx.dataview.DataViewItem` .. versionadded:: 2.9.2 .. seealso:: :meth:`SetCurrentItem` , :meth:`GetCurrentColumn` .. method:: GetExpanderColumn(self) Returns column containing the expanders. :rtype: :ref:`wx.dataview.DataViewColumn` .. method:: GetIndent(self) Returns indentation. :rtype: `int` .. method:: GetItemRect(self, item, col=None) Returns item rectangle. This method is currently not implemented at all in wxGTK and only implemented for not ``None`` `col` argument in wxOSX. It is fully implemented in the generic version of the control. :param `item`: A valid item. :type `item`: wx.dataview.DataViewItem :param `col`: If not ``None``, the rectangle returned corresponds to the intersection of the item with the specified column. If ``None``, the rectangle spans all the columns. :type `col`: wx.dataview.DataViewColumn :rtype: `Rect` .. method:: GetModel(self) Returns pointer to the data model associated with the control (if any). :rtype: :ref:`wx.dataview.DataViewModel` .. method:: GetSelectedItemsCount(self) Returns the number of currently selected items. This method may be called for both the controls with single and multiple selections and returns the number of selected item, possibly 0, in any case. :rtype: `int` .. versionadded:: 2.9.3 .. method:: GetSelection(self) Returns first selected item or an invalid item if none is selected. This method may be called for both the controls with single and multiple selections but returns an invalid item if more than one item is selected in the latter case, use :meth:`HasSelection` to determine if there are any selected items when using multiple selection. :rtype: :ref:`wx.dataview.DataViewItem` .. method:: GetSelections(self) Returns a list of the currently selected items. :rtype: `DataViewItemArray` .. method:: GetSortingColumn(self) Returns the :ref:`wx.dataview.DataViewColumn` currently responsible for sorting or ``None`` if none has been selected. :rtype: :ref:`wx.dataview.DataViewColumn` .. method:: HasSelection(self) Returns ``True`` if any items are currently selected. This method may be called for both the controls with single and multiple selections. Calling this method is equivalent to calling :meth:`GetSelectedItemsCount` and comparing its result with 0 but is more clear and might also be implemented more efficiently in the future. :rtype: `bool` .. versionadded:: 2.9.3 .. method:: HitTest(self, point) HitTest(point) . (item, col) Returns the item and column located at point, as a 2 element tuple. :rtype: `PyObject` .. method:: InsertColumn(self, pos, col) Inserts a :ref:`wx.dataview.DataViewColumn` to the control. Returns ``True`` on success. :param `pos`: :type `pos`: int :param `col`: :type `col`: wx.dataview.DataViewColumn :rtype: `bool` .. method:: IsExpanded(self, item) Return ``True`` if the item is expanded. :param `item`: :type `item`: wx.dataview.DataViewItem :rtype: `bool` .. method:: IsSelected(self, item) Return ``True`` if the item is selected. :param `item`: :type `item`: wx.dataview.DataViewItem :rtype: `bool` .. method:: PrependBitmapColumn(self, *args, **kw) Prepends a column for rendering a bitmap. Returns the :ref:`wx.dataview.DataViewColumn` created in the function or ``None`` on failure. |overload| Overloaded Implementations: **~~~** **PrependBitmapColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=-1, align=ALIGN_CENTER, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: string :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** **PrependBitmapColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=-1, align=ALIGN_CENTER, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: wx.Bitmap :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** .. method:: PrependColumn(self, col) Prepends a :ref:`wx.dataview.DataViewColumn` to the control. Returns ``True`` on success. Note that there is a number of short cut methods which implicitly create a :ref:`wx.dataview.DataViewColumn` and a :ref:`wx.dataview.DataViewRenderer` for it. :param `col`: :type `col`: wx.dataview.DataViewColumn :rtype: `bool` .. method:: PrependDateColumn(self, *args, **kw) Prepends a column for rendering a date. Returns the :ref:`wx.dataview.DataViewColumn` created in the function or ``None`` on failure. .. note:: The `align` parameter is applied to both the column header and the column renderer. |overload| Overloaded Implementations: **~~~** **PrependDateColumn** `(self, label, model_column, mode=DATAVIEW_CELL_ACTIVATABLE, width=-1, align=ALIGN_NOT, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: string :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** **PrependDateColumn** `(self, label, model_column, mode=DATAVIEW_CELL_ACTIVATABLE, width=-1, align=ALIGN_NOT, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: wx.Bitmap :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** .. method:: PrependIconTextColumn(self, *args, **kw) Prepends a column for rendering text with an icon. Returns the :ref:`wx.dataview.DataViewColumn` created in the function or ``None`` on failure. This method uses the :ref:`wx.dataview.DataViewIconTextRenderer` class. .. note:: The `align` parameter is applied to both the column header and the column renderer. |overload| Overloaded Implementations: **~~~** **PrependIconTextColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=-1, align=ALIGN_NOT, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: string :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** **PrependIconTextColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=-1, align=ALIGN_NOT, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: wx.Bitmap :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** .. method:: PrependProgressColumn(self, *args, **kw) Prepends a column for rendering a progress indicator. Returns the :ref:`wx.dataview.DataViewColumn` created in the function or ``None`` on failure. .. note:: The `align` parameter is applied to both the column header and the column renderer. |overload| Overloaded Implementations: **~~~** **PrependProgressColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=80, align=ALIGN_CENTER, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: string :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** **PrependProgressColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=80, align=ALIGN_CENTER, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: wx.Bitmap :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** .. method:: PrependTextColumn(self, *args, **kw) Prepends a column for rendering text. Returns the :ref:`wx.dataview.DataViewColumn` created in the function or ``None`` on failure. .. note:: The `align` parameter is applied to both the column header and the column renderer. |overload| Overloaded Implementations: **~~~** **PrependTextColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=-1, align=ALIGN_NOT, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: string :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** **PrependTextColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=-1, align=ALIGN_NOT, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: wx.Bitmap :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** .. method:: PrependToggleColumn(self, *args, **kw) Prepends a column for rendering a toggle. Returns the :ref:`wx.dataview.DataViewColumn` created in the function or ``None`` on failure. .. note:: The `align` parameter is applied to both the column header and the column renderer. |overload| Overloaded Implementations: **~~~** **PrependToggleColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=30, align=ALIGN_CENTER, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: string :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** **PrependToggleColumn** `(self, label, model_column, mode=DATAVIEW_CELL_INERT, width=30, align=ALIGN_CENTER, flags=DATAVIEW_COL_RESIZABLE)` :param `label`: :type `label`: wx.Bitmap :param `model_column`: :type `model_column`: int :param `mode`: :type `mode`: wx.dataview.DataViewCellMode :param `width`: :type `width`: int :param `align`: :type `align`: wx.Alignment :param `flags`: :type `flags`: int :rtype: :ref:`wx.dataview.DataViewColumn` **~~~** .. method:: Select(self, item) Select the given item. In single selection mode this changes the (unique) currently selected item. In multi selection mode, the `item` is selected and the previously selected items remain selected. :param `item`: :type `item`: wx.dataview.DataViewItem .. method:: SelectAll(self) Select all items. .. method:: SetCurrentItem(self, item) Changes the currently focused item. The `item` parameter must be valid, there is no way to remove the current item from the control. In single selection mode, calling this method is the same as calling :meth:`Select` and is thus not very useful. In multiple selection mode this method only moves the current item however without changing the selection except under OS X where the current item is always selected, so calling :meth:`SetCurrentItem` selects `item` if it hadn't been selected before. :param `item`: :type `item`: wx.dataview.DataViewItem .. versionadded:: 2.9.2 .. seealso:: :meth:`GetCurrentItem` .. method:: SetExpanderColumn(self, col) Set which column shall contain the tree-like expanders. :param `col`: :type `col`: wx.dataview.DataViewColumn .. method:: SetIndent(self, indent) Sets the indentation. :param `indent`: :type `indent`: int .. method:: SetRowHeight(self, rowHeight) Sets the row height. This function can only be used when all rows have the same height, i.e. when ``wx.dataview.DV_VARIABLE_LINE_HEIGHT`` flag is not used. Currently this is implemented in the generic and native GTK versions only and nothing is done (and ``False`` returned) when using OS X port. Also notice that this method can only be used to increase the row height compared with the default one (as determined by the return value of `DataViewRenderer.GetSize()),` if it is set to a too small value then the minimum required by the renderers will be used. :param `rowHeight`: :type `rowHeight`: int :rtype: `bool` :returns: ``True`` if the line height was changed or ``False`` otherwise. .. versionadded:: 2.9.2 .. method:: SetSelections(self, sel) Sets the selection to the array of DataViewItems. :param `sel`: :type `sel`: DataViewItemArray .. method:: Unselect(self, item) Unselect the given item. :param `item`: :type `item`: wx.dataview.DataViewItem .. method:: UnselectAll(self) Unselect all item. This method only has effect if multiple selections are allowed. .. attribute:: ColumnCount See :meth:`~wx.dataview.DataViewCtrl.GetColumnCount` .. attribute:: Columns See :meth:`~wx.dataview.DataViewCtrl.GetColumns` .. attribute:: CurrentColumn See :meth:`~wx.dataview.DataViewCtrl.GetCurrentColumn` .. attribute:: CurrentItem See :meth:`~wx.dataview.DataViewCtrl.GetCurrentItem` and :meth:`~wx.dataview.DataViewCtrl.SetCurrentItem` .. attribute:: ExpanderColumn See :meth:`~wx.dataview.DataViewCtrl.GetExpanderColumn` and :meth:`~wx.dataview.DataViewCtrl.SetExpanderColumn` .. attribute:: Indent See :meth:`~wx.dataview.DataViewCtrl.GetIndent` and :meth:`~wx.dataview.DataViewCtrl.SetIndent` .. attribute:: Model See :meth:`~wx.dataview.DataViewCtrl.GetModel` .. attribute:: SelectedItemsCount See :meth:`~wx.dataview.DataViewCtrl.GetSelectedItemsCount` .. attribute:: Selection See :meth:`~wx.dataview.DataViewCtrl.GetSelection` .. attribute:: Selections See :meth:`~wx.dataview.DataViewCtrl.GetSelections` and :meth:`~wx.dataview.DataViewCtrl.SetSelections` .. attribute:: SortingColumn See :meth:`~wx.dataview.DataViewCtrl.GetSortingColumn`