.. wxPython Phoenix documentation This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License .. include:: headings.inc .. _wx.ListCtrl: ========================================================================================================================================== |phoenix_title| **wx.ListCtrl** ========================================================================================================================================== A list control presents lists in a number of formats: list view, report view, icon view and small icon view. In any case, elements are numbered from zero. For all these modes, the items are stored in the control and must be added to it using :meth:`wx.ListCtrl.InsertItem` method. A special case of report view quite different from the other modes of the list control is a virtual control in which the items data (including text, images and attributes) is managed by the main program and is requested by the control itself only when needed which allows having controls with millions of items without consuming much memory. To use virtual list control you must use :meth:`wx.ListCtrl.SetItemCount` first and override at least :meth:`wx.ListCtrl.OnGetItemText` (and optionally :meth:`wx.ListCtrl.OnGetItemImage` or :meth:`wx.ListCtrl.OnGetItemColumnImage` and :meth:`wx.ListCtrl.OnGetItemAttr` ) to return the information about the items when the control requests it. Virtual list control can be used as a normal one except that no operations which can take time proportional to the number of items in the control happen – this is required to allow having a practically infinite number of items. For example, in a multiple selection virtual list control, the selections won't be sent when many items are selected at once because this could mean iterating over all the items. Using many of :ref:`wx.ListCtrl` features is shown in the :ref:`corresponding sample `. To intercept events from a list control, use the event table macros described in :ref:`wx.ListEvent`. |phoenix_title| Column Ordering =============================== By default, the columns of a list control appear on the screen in order of their indices, i.e. column 0 appears first, then column 1 next, and so on. However this can be changed by using the :meth:`~wx.ListCtrl.SetColumnsOrder` function to arbitrarily reorder the columns visual order. The user can also rearrange the columns interactively by dragging them. In this case, the index of the column is not the same as its order and the functions :meth:`~wx.ListCtrl.GetColumnOrder` and :meth:`~wx.ListCtrl.GetColumnIndexFromOrder` should be used to translate between them. Example of reordering columns: :: listctrl = wx.ListCtrl(...) for i in range(3): listctrl.InsertColumn(i, wx.String.Format("Column %d", i)) order = [ 2, 0, 1] listctrl.SetColumnsOrder(order) # Now listctrl.GetColumnsOrder() will return order and # listctrl.GetColumnIndexFromOrder(n) will return order[n] and # listctrl.GetColumnOrder() will return 1, 2 and 0 for the column 0, 1 and 2 # respectively. .. _ListCtrl-styles: |styles| Window Styles ================================ ^^ This class supports the following styles: - ``wx.LC_LIST``: Multicolumn list view, with optional small icons. Columns are computed automatically, i.e. you don't set columns as in ``LC_REPORT`` . In other words, the list wraps, unlike a :ref:`wx.ListBox`. - ``wx.LC_REPORT``: Single or multicolumn report view, with optional header. - ``wx.LC_VIRTUAL``: The application provides items text on demand. May only be used with ``LC_REPORT`` . - ``wx.LC_ICON``: Large icon view, with optional labels. - ``wx.LC_SMALL_ICON``: Small icon view, with optional labels. - ``wx.LC_ALIGN_TOP``: Icons align to the top. Win32 default, Win32 only. - ``wx.LC_ALIGN_LEFT``: Icons align to the left. - ``wx.LC_AUTOARRANGE``: Icons arrange themselves. Win32 only. - ``wx.LC_EDIT_LABELS``: Labels are editable: the application will be notified when editing starts. - ``wx.LC_NO_HEADER``: No header in report mode. - ``wx.LC_SINGLE_SEL``: Single selection (default is multiple). - ``wx.LC_SORT_ASCENDING``: Sort in ascending order. (You must still supply a comparison callback in :meth:`wx.ListCtrl.SortItems` .) - ``wx.LC_SORT_DESCENDING``: Sort in descending order. (You must still supply a comparison callback in :meth:`wx.ListCtrl.SortItems` .) - ``wx.LC_HRULES``: Draws light horizontal rules between rows in report mode. - ``wx.LC_VRULES``: Draws light vertical rules between columns in report mode. ^^ ^^ .. _ListCtrl-events: |events| Events Emitted by this Class ===================================== Handlers bound for the following event types will receive one of the :ref:`wx.ListEvent` parameters. - EVT_LIST_BEGIN_DRAG: Begin dragging with the left mouse button. Processes a ``wxEVT_LIST_BEGIN_DRAG`` event type. - EVT_LIST_BEGIN_RDRAG: Begin dragging with the right mouse button. Processes a ``wxEVT_LIST_BEGIN_RDRAG`` event type. - EVT_LIST_BEGIN_LABEL_EDIT: Begin editing a label. This can be prevented by calling Veto(). Processes a ``wxEVT_LIST_BEGIN_LABEL_EDIT`` event type. - EVT_LIST_END_LABEL_EDIT: Finish editing a label. This can be prevented by calling Veto(). Processes a ``wxEVT_LIST_END_LABEL_EDIT`` event type. - EVT_LIST_DELETE_ITEM: An item was deleted. Processes a ``wxEVT_LIST_DELETE_ITEM`` event type. - EVT_LIST_DELETE_ALL_ITEMS: All items were deleted. Processes a ``wxEVT_LIST_DELETE_ALL_ITEMS`` event type. - EVT_LIST_ITEM_SELECTED: The item has been selected. Notice that the mouse is captured by the control itself when this event is generated, see :ref:`event handling overview `. Processes a ``wxEVT_LIST_ITEM_SELECTED`` event type. - EVT_LIST_ITEM_DESELECTED: The item has been deselected. Processes a ``wxEVT_LIST_ITEM_DESELECTED`` event type. - EVT_LIST_ITEM_ACTIVATED: The item has been activated (``ENTER`` or double click). Processes a ``wxEVT_LIST_ITEM_ACTIVATED`` event type. - EVT_LIST_ITEM_FOCUSED: The currently focused item has changed. Processes a ``wxEVT_LIST_ITEM_FOCUSED`` event type. - EVT_LIST_ITEM_MIDDLE_CLICK: The middle mouse button has been clicked on an item. This is only supported by the generic control. Processes a ``wxEVT_LIST_ITEM_MIDDLE_CLICK`` event type. - EVT_LIST_ITEM_RIGHT_CLICK: The right mouse button has been clicked on an item. Processes a ``wxEVT_LIST_ITEM_RIGHT_CLICK`` event type. - EVT_LIST_KEY_DOWN: A key has been pressed. Processes a ``wxEVT_LIST_KEY_DOWN`` event type. - EVT_LIST_INSERT_ITEM: An item has been inserted. Processes a ``wxEVT_LIST_INSERT_ITEM`` event type. - EVT_LIST_COL_CLICK: A column (m_col) has been left-clicked. Processes a ``wxEVT_LIST_COL_CLICK`` event type. - EVT_LIST_COL_RIGHT_CLICK: A column (m_col) has been right-clicked. Processes a ``wxEVT_LIST_COL_RIGHT_CLICK`` event type. - EVT_LIST_COL_BEGIN_DRAG: The user started resizing a column - can be vetoed. Processes a ``wxEVT_LIST_COL_BEGIN_DRAG`` event type. - EVT_LIST_COL_DRAGGING: The divider between columns is being dragged. Processes a ``wxEVT_LIST_COL_DRAGGING`` event type. - EVT_LIST_COL_END_DRAG: A column has been resized by the user. Processes a ``wxEVT_LIST_COL_END_DRAG`` event type. - EVT_LIST_CACHE_HINT: Prepare cache for a virtual list control. Processes a ``wxEVT_LIST_CACHE_HINT`` event type. - EVT_LIST_ITEM_CHECKED: The item has been checked. Processes a ``wxEVT_LIST_ITEM_CHECKED`` event type (new since wxWidgets 3.1.0). - EVT_LIST_ITEM_UNCHECKED: The item has been unchecked. Processes a ``wxEVT_LIST_ITEM_UNCHECKED`` event type (new since wxWidgets 3.1.0). ^^ .. note:: The native wxOSX implementation for report mode that was added in wxWidgets 2.8 was removed in wxWidgets 3.1, meaning for wxWidgets 3.1+ wxOSX uses the generic implementation for all modes. .. note:: All the other functions still work with the column indices, i.e. the visual positioning of the columns on screen doesn't affect the code setting or getting their values for example. .. note:: Under wxMSW this control uses `SystemThemedControl` for an explorer style appearance by default since wxWidgets 3.1.0. If this is not desired, you can call :meth:`SystemThemedControl.EnableSystemTheme` with ``false`` argument to disable this. .. seealso:: :ref:`ListCtrl Overview `, :ref:`wx.ListView`, :ref:`wx.ListBox`, :ref:`wx.TreeCtrl`, :ref:`wx.ImageList`, :ref:`wx.ListEvent`, :ref:`wx.ListItem`, :ref:`wx.adv.EditableListBox` | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class ListCtrl:
| |appearance| Control Appearance =============================== | .. figure:: _static/images/widgets/fullsize/wxmsw/wx.listctrl.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: _static/images/widgets/fullsize/wxmac/wx.listctrl.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: _static/images/widgets/fullsize/wxgtk/wx.listctrl.png :alt: wxGTK :figclass: floatcenter **wxGTK** | |sub_classes| Known Subclasses ============================== :ref:`wx.ListView` | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.ListCtrl.__init__` Default constructor. :meth:`~wx.ListCtrl.Append` Append an item to the list control. The `entry` parameter should be a :meth:`~wx.ListCtrl.AppendColumn` Adds a new column to the list control in report view mode. :meth:`~wx.ListCtrl.Arrange` Arranges the items in icon or small icon view. :meth:`~wx.ListCtrl.AssignImageList` Sets the image list associated with the control and takes ownership of it. :meth:`~wx.ListCtrl.CheckItem` Check or uncheck a :ref:`wx.ListItem` in a control using checkboxes. :meth:`~wx.ListCtrl.ClearAll` Deletes all items and all columns. :meth:`~wx.ListCtrl.ClearColumnImage` :meth:`~wx.ListCtrl.Create` Creates the list control. :meth:`~wx.ListCtrl.DeleteAllColumns` Delete all columns in the list control. :meth:`~wx.ListCtrl.DeleteAllItems` Deletes all items in the list control. :meth:`~wx.ListCtrl.DeleteColumn` Deletes a column. :meth:`~wx.ListCtrl.DeleteItem` Deletes the specified item. :meth:`~wx.ListCtrl.EditLabel` Starts editing the label of the given item. :meth:`~wx.ListCtrl.EnableAlternateRowColours` Enable alternating row background colours (also called zebra striping). :meth:`~wx.ListCtrl.EnableBellOnNoMatch` Enable or disable a beep if there is no match for the currently entered text when searching for the item from keyboard. :meth:`~wx.ListCtrl.EnableCheckBoxes` Enable or disable checkboxes for list items. :meth:`~wx.ListCtrl.EnableSystemTheme` Can be used to disable the system theme of controls using it by default. :meth:`~wx.ListCtrl.EnsureVisible` Ensures this item is visible. :meth:`~wx.ListCtrl.ExtendRulesAndAlternateColour` Extend rules and alternate rows background to the entire client area. :meth:`~wx.ListCtrl.FindItem` Find an item whose label matches this string, starting from start or the beginning if start is ``-1`` . :meth:`~wx.ListCtrl.Focus` Focus and show the given item. :meth:`~wx.ListCtrl.GetAlternateRowColour` Get the alternative row background colour. :meth:`~wx.ListCtrl.GetClassDefaultAttributes` :meth:`~wx.ListCtrl.GetColumn` Gets information about this column. See SetItem() for more information. :meth:`~wx.ListCtrl.GetColumnCount` Returns the number of columns. :meth:`~wx.ListCtrl.GetColumnIndexFromOrder` Gets the column index from its position in visual order. :meth:`~wx.ListCtrl.GetColumnOrder` Gets the column visual order position. :meth:`~wx.ListCtrl.GetColumnWidth` Gets the column width (report view only). :meth:`~wx.ListCtrl.GetColumnsOrder` Returns the array containing the orders of all columns. :meth:`~wx.ListCtrl.GetCountPerPage` Gets the number of items that can fit vertically in the visible area of the list control (list or report view) or the total number of items in the list control (icon or small icon view). :meth:`~wx.ListCtrl.GetEditControl` Returns the edit control being currently used to edit a label. :meth:`~wx.ListCtrl.GetFirstSelected` Returns the first selected item, or -1 when none is selected. :meth:`~wx.ListCtrl.GetFocusedItem` Gets the currently focused item or -1 if none is focused. :meth:`~wx.ListCtrl.GetImageList` Returns the specified image list. :meth:`~wx.ListCtrl.GetItem` Gets information about the item. See SetItem() for more information. :meth:`~wx.ListCtrl.GetItemBackgroundColour` Returns the colour for this item. :meth:`~wx.ListCtrl.GetItemCount` Returns the number of items in the list control. :meth:`~wx.ListCtrl.GetItemData` Gets the application-defined data associated with this item. :meth:`~wx.ListCtrl.GetItemFont` Returns the item's font. :meth:`~wx.ListCtrl.GetItemPosition` Returns the position of the item, in icon or small icon view. :meth:`~wx.ListCtrl.GetItemRect` Returns the rectangle representing the item's size and position, in physical coordinates. :meth:`~wx.ListCtrl.GetItemSpacing` Retrieves the spacing between icons in pixels: horizontal spacing is returned as ``x`` component of the :ref:`wx.Size` object and the vertical spacing as its ``y`` component. :meth:`~wx.ListCtrl.GetItemState` Gets the item state. :meth:`~wx.ListCtrl.GetItemText` Gets the item text for this item. :meth:`~wx.ListCtrl.GetItemTextColour` Returns the colour for this item. :meth:`~wx.ListCtrl.GetMainWindow` :meth:`~wx.ListCtrl.GetNextItem` Searches for an item with the given geometry or state, starting from `item` but excluding the `item` itself. :meth:`~wx.ListCtrl.GetNextSelected` Returns subsequent selected items, or -1 when no more are selected. :meth:`~wx.ListCtrl.GetSelectedItemCount` Returns the number of selected items in the list control. :meth:`~wx.ListCtrl.GetSortIndicator` Returns the column that shows the sort indicator. :meth:`~wx.ListCtrl.GetSubItemRect` Returns the rectangle representing the size and position, in physical coordinates, of the given subitem, i.e. :meth:`~wx.ListCtrl.GetTextColour` Gets the text colour of the list control. :meth:`~wx.ListCtrl.GetTopItem` Gets the index of the topmost visible item when in list or report view. :meth:`~wx.ListCtrl.GetUpdatedAscendingSortIndicator` Returns the new value to use for sort indicator after clicking a column. :meth:`~wx.ListCtrl.GetViewRect` Returns the rectangle taken by all items in the control. :meth:`~wx.ListCtrl.HasCheckBoxes` Returns ``True`` if checkboxes are enabled for list items. :meth:`~wx.ListCtrl.HasColumnOrderSupport` :meth:`~wx.ListCtrl.HitTest` Determines which item (if any) is at the specified point, giving details in `flags`. :meth:`~wx.ListCtrl.HitTestSubItem` Determines which item (if any) is at the specified point, giving details in flags. :meth:`~wx.ListCtrl.InReportView` Returns ``True`` if the control is currently using ``LC_REPORT`` style. :meth:`~wx.ListCtrl.InsertColumn` For report view mode (only), inserts a column. :meth:`~wx.ListCtrl.InsertItem` Inserts an item, returning the index of the new item if successful, -1 otherwise. :meth:`~wx.ListCtrl.IsAscendingSortIndicator` Returns ``True`` if the sort indicator direction is ascending, ``False`` when the direction is descending. :meth:`~wx.ListCtrl.IsEmpty` Returns ``True`` if the control doesn't currently contain any items. :meth:`~wx.ListCtrl.IsItemChecked` Return ``True`` if the checkbox for the given :ref:`wx.ListItem` is checked. :meth:`~wx.ListCtrl.IsSelected` Returns ``True`` if the item is selected. :meth:`~wx.ListCtrl.IsVirtual` Returns ``True`` if the control is currently in virtual report view. :meth:`~wx.ListCtrl.IsVisible` Check if the item is visible. :meth:`~wx.ListCtrl.OnGetItemAttr` This function may be overridden in the derived class for a control with ``LC_VIRTUAL`` style. :meth:`~wx.ListCtrl.OnGetItemColumnImage` Override this function in the derived class for a control with ``LC_VIRTUAL`` and ``LC_REPORT`` styles in order to specify the image index for the given line and column. :meth:`~wx.ListCtrl.OnGetItemImage` This function must be overridden in the derived class for a control with ``LC_VIRTUAL`` style using images. :meth:`~wx.ListCtrl.OnGetItemIsChecked` This function **must** be overridden in the derived class for a control with ``LC_VIRTUAL`` style that uses checkboxes. :meth:`~wx.ListCtrl.OnGetItemText` This function **must** be overridden in the derived class for a control with ``LC_VIRTUAL`` style. :meth:`~wx.ListCtrl.RefreshItem` Redraws the given `item`. :meth:`~wx.ListCtrl.RefreshItems` Redraws the items between `itemFrom` and `itemTo`. :meth:`~wx.ListCtrl.RemoveSortIndicator` Remove the sort indicator from the column being used as sort key. :meth:`~wx.ListCtrl.ScrollList` Scrolls the list control. :meth:`~wx.ListCtrl.Select` Selects/deselects an item. :meth:`~wx.ListCtrl.SetAlternateRowColour` Set the alternative row background colour to a specific colour. :meth:`~wx.ListCtrl.SetBackgroundColour` Sets the background colour. :meth:`~wx.ListCtrl.SetColumn` Sets information about this column. :meth:`~wx.ListCtrl.SetColumnImage` :meth:`~wx.ListCtrl.SetColumnWidth` Sets the column width. :meth:`~wx.ListCtrl.SetColumnsOrder` Changes the order in which the columns are shown. :meth:`~wx.ListCtrl.SetHeaderAttr` Change the font and the colours used for the list control header. :meth:`~wx.ListCtrl.SetImageList` Sets the image list associated with the control. :meth:`~wx.ListCtrl.SetItem` Sets the data of an item. :meth:`~wx.ListCtrl.SetItemBackgroundColour` Sets the background colour for this item. :meth:`~wx.ListCtrl.SetItemColumnImage` Sets the image associated with the item. :meth:`~wx.ListCtrl.SetItemCount` This method can only be used with virtual list controls. :meth:`~wx.ListCtrl.SetItemData` Associates application-defined data with this item. :meth:`~wx.ListCtrl.SetItemFont` Sets the item's font. :meth:`~wx.ListCtrl.SetItemImage` Sets the unselected and selected images associated with the item. :meth:`~wx.ListCtrl.SetItemPosition` Sets the position of the item, in icon or small icon view. :meth:`~wx.ListCtrl.SetItemState` Sets the item state. :meth:`~wx.ListCtrl.SetItemText` Sets the item text for this item. :meth:`~wx.ListCtrl.SetItemTextColour` Sets the colour for this item. :meth:`~wx.ListCtrl.SetNormalImages` Sets the images to use when showing large, normal icons in this control. :meth:`~wx.ListCtrl.SetSingleStyle` Adds or removes a single window style. :meth:`~wx.ListCtrl.SetSmallImages` Sets the images to use when showing small icons in this control. :meth:`~wx.ListCtrl.SetTextColour` Sets the text colour of the list control. :meth:`~wx.ListCtrl.SetWindowStyleFlag` Sets the whole window style, deleting all items. :meth:`~wx.ListCtrl.ShowSortIndicator` Show the sort indicator of a specific column in a specific direction. :meth:`~wx.ListCtrl.SortItems` Call this function to sort the items in the list control. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~wx.ListCtrl.AlternateRowColour` See :meth:`~wx.ListCtrl.GetAlternateRowColour` and :meth:`~wx.ListCtrl.SetAlternateRowColour` :attr:`~wx.ListCtrl.Column` See :meth:`~wx.ListCtrl.GetColumn` and :meth:`~wx.ListCtrl.SetColumn` :attr:`~wx.ListCtrl.ColumnCount` See :meth:`~wx.ListCtrl.GetColumnCount` :attr:`~wx.ListCtrl.ColumnsOrder` See :meth:`~wx.ListCtrl.GetColumnsOrder` and :meth:`~wx.ListCtrl.SetColumnsOrder` :attr:`~wx.ListCtrl.CountPerPage` See :meth:`~wx.ListCtrl.GetCountPerPage` :attr:`~wx.ListCtrl.EditControl` See :meth:`~wx.ListCtrl.GetEditControl` :attr:`~wx.ListCtrl.FocusedItem` See :meth:`~wx.ListCtrl.GetFocusedItem` :attr:`~wx.ListCtrl.Item` See :meth:`~wx.ListCtrl.GetItem` and :meth:`~wx.ListCtrl.SetItem` :attr:`~wx.ListCtrl.ItemCount` See :meth:`~wx.ListCtrl.GetItemCount` and :meth:`~wx.ListCtrl.SetItemCount` :attr:`~wx.ListCtrl.ItemPosition` See :meth:`~wx.ListCtrl.GetItemPosition` and :meth:`~wx.ListCtrl.SetItemPosition` :attr:`~wx.ListCtrl.ItemRect` See :meth:`~wx.ListCtrl.GetItemRect` :attr:`~wx.ListCtrl.ItemSpacing` See :meth:`~wx.ListCtrl.GetItemSpacing` :attr:`~wx.ListCtrl.MainWindow` See :meth:`~wx.ListCtrl.GetMainWindow` :attr:`~wx.ListCtrl.SelectedItemCount` See :meth:`~wx.ListCtrl.GetSelectedItemCount` :attr:`~wx.ListCtrl.SortIndicator` See :meth:`~wx.ListCtrl.GetSortIndicator` :attr:`~wx.ListCtrl.TextColour` See :meth:`~wx.ListCtrl.GetTextColour` and :meth:`~wx.ListCtrl.SetTextColour` :attr:`~wx.ListCtrl.TopItem` See :meth:`~wx.ListCtrl.GetTopItem` :attr:`~wx.ListCtrl.ViewRect` See :meth:`~wx.ListCtrl.GetViewRect` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: wx.ListCtrl(Control) **Possible constructors**:: ListCtrl() ListCtrl(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=LC_ICON, validator=DefaultValidator, name=ListCtrlNameStr) A list control presents lists in a number of formats: list view, report view, icon view and small icon view. .. method:: __init__(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **__init__** `(self)` Default constructor. :html:`

` **__init__** `(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=LC_ICON, validator=DefaultValidator, name=ListCtrlNameStr)` Constructor, creating and showing a list control. :param `parent`: Parent window. Must not be ``None``. :type `parent`: wx.Window :param `id`: Window identifier. The value ``wx.ID_ANY`` indicates a default value. :type `id`: wx.WindowID :param `pos`: Window position. If `wx.DefaultPosition` is specified then a default position is chosen. :type `pos`: wx.Point :param `size`: Window size. If `wx.DefaultSize` is specified then the window is sized appropriately. :type `size`: wx.Size :param `style`: Window style. See :ref:`wx.ListCtrl`. :type `style`: long :param `validator`: Window validator. :type `validator`: wx.Validator :param `name`: Window name. :type `name`: string .. seealso:: :meth:`Create` , :ref:`wx.Validator` :html:`

` .. method:: Append(self, entry) Append an item to the list control. The `entry` parameter should be a sequence with an item for each column .. method:: AppendColumn(self, heading, format=LIST_FORMAT_LEFT, width=-1) Adds a new column to the list control in report view mode. This is just a convenient wrapper for :meth:`InsertColumn` which adds the new column after all the existing ones without having to specify its position explicitly. :param `heading`: :type `heading`: string :param `format`: :type `format`: wx.ListColumnFormat :param `width`: :type `width`: int :rtype: `long` .. versionadded:: 2.9.4 .. method:: Arrange(self, flag=LIST_ALIGN_DEFAULT) Arranges the items in icon or small icon view. This only has effect on Win32. `flag` is one of: - ``wx.LIST_ALIGN_DEFAULT``: Default alignment. - ``wx.LIST_ALIGN_LEFT``: Align to the left side of the control. - ``wx.LIST_ALIGN_TOP``: Align to the top side of the control. - ``wx.LIST_ALIGN_SNAP_TO_GRID``: Snap to grid. :param `flag`: :type `flag`: int :rtype: `bool` .. method:: AssignImageList(self, imageList, which) Sets the image list associated with the control and takes ownership of it. Not that it is recommended to use :meth:`SetNormalImages` or :meth:`SetSmallImages` instead of this function in the new code. After calling this function the control will, unlike when using :meth:`SetImageList` , delete the list when destroyed. `which` must be one of ``IMAGE_LIST_NORMAL`` , ``IMAGE_LIST_SMALL`` , ``IMAGE_LIST_STATE`` (support for the last one is unimplemented). :param `imageList`: :type `imageList`: wx.ImageList :param `which`: :type `which`: int .. seealso:: :meth:`SetImageList` .. method:: CheckItem(self, item, check=True) Check or uncheck a :ref:`wx.ListItem` in a control using checkboxes. This method only works if checkboxes support had been successfully enabled using :meth:`EnableCheckBoxes` . :param `item`: Item (zero-based) index. :type `item`: long :param `check`: If ``True``, check the item, otherwise uncheck. :type `check`: bool .. versionadded:: 4.1/wxWidgets-3.1.0 .. method:: ClearAll(self) Deletes all items and all columns. .. note:: This sends an event of type ``wxEVT_LIST_DELETE_ALL_ITEMS`` under all platforms. .. method:: ClearColumnImage(self, col) .. method:: Create(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=LC_ICON, validator=DefaultValidator, name=ListCtrlNameStr) Creates the list control. See :ref:`wx.ListCtrl` for further details. :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:: DeleteAllColumns(self) Delete all columns in the list control. :rtype: `bool` :returns: ``True`` if all columns were successfully deleted, ``False`` otherwise. .. method:: DeleteAllItems(self) Deletes all items in the list control. This function does `not` send the ``wxEVT_LIST_DELETE_ITEM`` event because deleting many items from the control would be too slow then (unlike :meth:`wx.ListCtrl.DeleteItem` ) but it does send the special ``wxEVT_LIST_DELETE_ALL_ITEMS`` event if the control was not empty. If it was already empty, nothing is done and no event is sent. :rtype: `bool` :returns: ``True`` if the items were successfully deleted or if the control was already empty, ``False`` if an error occurred while deleting the items. .. method:: DeleteColumn(self, col) Deletes a column. :param `col`: :type `col`: int :rtype: `bool` .. method:: DeleteItem(self, item) Deletes the specified item. This function sends the ``wxEVT_LIST_DELETE_ITEM`` event for the item being deleted. :param `item`: :type `item`: long :rtype: `bool` .. seealso:: :meth:`DeleteAllItems` .. method:: EditLabel(self, item) Starts editing the label of the given item. This function generates a ``EVT_LIST_BEGIN_LABEL_EDIT`` event which can be vetoed so that no text control will appear for in-place editing. If the user changed the label (i.e. s/he does not press ``ESC`` or leave the text control without changes, a ``EVT_LIST_END_LABEL_EDIT`` event will be sent which can be vetoed as well. :param `item`: :type `item`: long :rtype: :ref:`wx.TextCtrl` .. method:: EnableAlternateRowColours(self, enable=True) Enable alternating row background colours (also called zebra striping). This method can only be called for the control in virtual report mode, i.e. having ``LC_REPORT`` and ``LC_VIRTUAL`` styles. When enabling alternating colours, the appropriate colour for the even rows is chosen automatically depending on the default foreground and background colours which are used for the odd rows. :param `enable`: If ``True``, enable alternating row background colours, i.e. different colours for the odd and even rows. If ``False``, disable this feature and use the same background colour for all rows. :type `enable`: bool .. versionadded:: 2.9.5 .. seealso:: :meth:`SetAlternateRowColour` .. method:: EnableBellOnNoMatch(self, on=True) Enable or disable a beep if there is no match for the currently entered text when searching for the item from keyboard. The default is to not beep in this case except in wxMSW where the beep is always generated by the native control and cannot be disabled, i.e. calls to this function do nothing there. :param `on`: :type `on`: bool .. versionadded:: 2.9.5 .. method:: EnableCheckBoxes(self, enable=True) Enable or disable checkboxes for list items. :param `enable`: If ``True``, enable checkboxes, otherwise disable checkboxes. :type `enable`: bool :rtype: `bool` In a list control with ``wx.LC_VIRTUAL`` style you have to keep track of the checkbox state. When a checkbox is clicked (``EVT_LIST_ITEM_CHECKED`` or ``EVT_LIST_ITEM_UNCHECKED``) you have to update the state and refresh the item yourself. :returns: ``True`` if checkboxes are supported, ``False`` otherwise. .. versionadded:: 4.1/wxWidgets-3.1.0 .. seealso:: :meth:`OnGetItemIsChecked` :meth:`RefreshItem` .. method:: EnableSystemTheme(self, enable=True) Can be used to disable the system theme of controls using it by default. On Windows there an alternative theme available for the list and list-like controls since Windows Vista. This theme is used by Windows Explorer list and tree view and so is arguably more familiar to the users than the standard appearance of these controls. This class automatically uses the new theme, but if that is not desired then this method can be used to turn it off. Please note that this method should be called before the widget is actually created, using the 2-phase create pattern. Something like this:: # This creates the object, but not the window widget = wx.ListCtrl() # Disable the system theme widget.EnableSystemTheme(False) # Now create the window widget.Create(parent, wx.``wx.ID_ANY``) This method has no effect on other platorms :param `enable`: :type `enable`: bool .. method:: EnsureVisible(self, item) Ensures this item is visible. :param `item`: :type `item`: long :rtype: `bool` .. method:: ExtendRulesAndAlternateColour(self, extend=True) Extend rules and alternate rows background to the entire client area. By default, the rules (when enabled with ``wx.LC_HRULES`` and ``wx.LC_VRULES``) and alternate row background (when :meth:`EnableAlternateRowColours` was called) are only shown in the part of the control occupied by the items, which can be smaller than the entire window if there are few items in the control. Calling this function extends the display of the rules and alternate background rows to the entire client area. Similarly to :meth:`EnableAlternateRowColours` , this method can only be used with controls having ``LC_REPORT`` and ``LC_VIRTUAL`` styles. Note that this method is currently not implemented in the native MSW version and does nothing there. :param `extend`: if ``True``, draws horizontal rules and vertical rules on empty rows and uses the colour parameter to paint the background of alternate rows when those rows are blank, empty, with no data. :type `extend`: bool .. versionadded:: 4.1/wxWidgets-3.1.5 .. method:: FindItem(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **FindItem** `(self, start, str, partial=False)` Find an item whose label matches this string, starting from start or the beginning if start is ``-1`` . The string comparison is case insensitive. If `partial` is ``True`` then this method will look for items which begin with `str`. :param `start`: :type `start`: long :param `str`: :type `str`: string :param `partial`: :type `partial`: bool :rtype: `long` :returns: The next matching item if any or ``-1`` (wx``wx.NOT_FOUND``) otherwise. :html:`

` **FindItem** `(self, start, data)` Find an item whose data matches this data, starting from start or the beginning if 'start' is ``-1`` . :html:`

` **FindItem** `(self, start, pt, direction)` Find an item nearest this position in the specified direction, starting from `start` or the beginning if `start` is -1. :html:`

` .. method:: Focus(self, idx) Focus and show the given item. .. method:: GetAlternateRowColour(self) Get the alternative row background colour. :rtype: :ref:`wx.Colour` .. versionadded:: 4.1/wxWidgets-3.1.0 .. seealso:: :meth:`SetAlternateRowColour` .. staticmethod:: GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL) :param `variant`: :type `variant`: wx.WindowVariant :rtype: :ref:`wx.VisualAttributes` .. method:: GetColumn(self, col) Gets information about this column. See SetItem() for more information. :rtype: :ref:`wx.ListItem` .. method:: GetColumnCount(self) Returns the number of columns. The control can have multiple columns only in ``wx.LC_REPORT`` mode. In ``wx.LC_LIST`` mode this function returns 1, as a list is still considered to have a (single) column. In ``wx.LC_SMALL_ICON`` and ``wx.LC_ICON`` modes, it returns 0 as there are no columns at all. :rtype: `int` .. method:: GetColumnIndexFromOrder(self, pos) Gets the column index from its position in visual order. After calling :meth:`SetColumnsOrder` , the index returned by this function corresponds to the value of the element number `pos` in the array returned by :meth:`GetColumnsOrder` . :param `pos`: :type `pos`: int :rtype: `int` .. note:: This function makes sense for report view only and currently is only implemented in the wxMSW port. Use ``HAS_LISTCTRL_COLUMN_ORDER`` to guard uses of this function so that they will start working under the other platforms when support for the column reordering is added there. .. seealso:: :meth:`GetColumnOrder` .. method:: GetColumnOrder(self, col) Gets the column visual order position. This function returns the index of the column which appears at the given visual position, e.g. calling it with `col` equal to 0 returns the index of the first shown column. :param `col`: :type `col`: int :rtype: `int` .. note:: This function makes sense for report view only and currently is only implemented in the wxMSW port. Use ``HAS_LISTCTRL_COLUMN_ORDER`` to guard uses of this function so that they will start working under the other platforms when support for the column reordering is added there. .. seealso:: :meth:`GetColumnsOrder` , :meth:`GetColumnIndexFromOrder` .. method:: GetColumnWidth(self, col) Gets the column width (report view only). :param `col`: :type `col`: int :rtype: `int` .. method:: GetColumnsOrder(self) Returns the array containing the orders of all columns. On error, an empty array is returned. :rtype: `list of integers` .. note:: This function makes sense for report view only and currently is only implemented in the wxMSW port. Use ``HAS_LISTCTRL_COLUMN_ORDER`` to guard uses of this function so that they will start working under the other platforms when support for the column reordering is added there. .. seealso:: :meth:`GetColumnOrder` , :meth:`GetColumnIndexFromOrder` .. method:: GetCountPerPage(self) Gets the number of items that can fit vertically in the visible area of the list control (list or report view) or the total number of items in the list control (icon or small icon view). :rtype: `int` .. method:: GetEditControl(self) Returns the edit control being currently used to edit a label. Returns ``None`` if no label is being edited. :rtype: :ref:`wx.TextCtrl` .. note:: It is currently only implemented for wxMSW and the generic version, not for the native macOS version. .. method:: GetFirstSelected(self, *args) Returns the first selected item, or -1 when none is selected. .. method:: GetFocusedItem(self) Gets the currently focused item or -1 if none is focused. .. method:: GetImageList(self, which) Returns the specified image list. `which` may be one of: - ``wx.IMAGE_LIST_NORMAL``: The normal (large icon) image list. - ``wx.IMAGE_LIST_SMALL``: The small icon image list. - ``wx.IMAGE_LIST_STATE``: The user-defined state image list (unimplemented). :param `which`: :type `which`: int :rtype: :ref:`wx.ImageList` .. method:: GetItem(self, itemIdx, col=0) Gets information about the item. See SetItem() for more information. :rtype: :ref:`wx.ListItem` .. method:: GetItemBackgroundColour(self, item) Returns the colour for this item. If the item has no specific colour, returns an invalid colour (and not the default background colour of the control itself). :param `item`: :type `item`: long :rtype: :ref:`wx.Colour` .. seealso:: :meth:`GetItemTextColour` .. method:: GetItemCount(self) Returns the number of items in the list control. :rtype: `int` .. method:: GetItemData(self, item) Gets the application-defined data associated with this item. :param `item`: :type `item`: long :rtype: `long` .. method:: GetItemFont(self, item) Returns the item's font. :param `item`: :type `item`: long :rtype: :ref:`wx.Font` .. method:: GetItemPosition(self, item) Returns the position of the item, in icon or small icon view. :rtype: :ref:`wx.Point` .. method:: GetItemRect(self, item, code=LIST_RECT_BOUNDS) Returns the rectangle representing the item's size and position, in physical coordinates. code is one of wx.``wx.LIST_RECT_BOUNDS``, wx.``wx.LIST_RECT_ICON``, wx.``wx.LIST_RECT_LABEL``. :rtype: :ref:`wx.Rect` .. method:: GetItemSpacing(self) Retrieves the spacing between icons in pixels: horizontal spacing is returned as ``x`` component of the :ref:`wx.Size` object and the vertical spacing as its ``y`` component. :rtype: :ref:`wx.Size` .. method:: GetItemState(self, item, stateMask) Gets the item state. For a list of state flags, see :meth:`SetItem` . The `stateMask` indicates which state flags are of interest. :param `item`: :type `item`: long :param `stateMask`: :type `stateMask`: long :rtype: `int` .. method:: GetItemText(self, item, col=0) Gets the item text for this item. :param `item`: Item (zero-based) index. :type `item`: long :param `col`: Item column (zero-based) index. Column 0 is the default. This parameter is new in wxWidgets 2.9.1. :type `col`: int :rtype: `string` .. method:: GetItemTextColour(self, item) Returns the colour for this item. If the item has no specific colour, returns an invalid colour (and not the default foreground colour of the control itself as this wouldn't allow distinguishing between items having the same colour as the current control foreground and items with default colour which, hence, have always the same colour as the control). :param `item`: :type `item`: long :rtype: :ref:`wx.Colour` .. method:: GetMainWindow(self) :rtype: :ref:`wx.Window` .. method:: GetNextItem(self, item, geometry=LIST_NEXT_ALL, state=LIST_STATE_DONTCARE) Searches for an item with the given geometry or state, starting from `item` but excluding the `item` itself. If `item` is -1, the first item that matches the specified flags will be returned. Returns the first item with given state following `item` or -1 if no such item found. This function may be used to find all selected items in the control like this: :: item = -1 while 1: item = listctrl.GetNextItem(item, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) if item == -1: break # This item is selected - do whatever is needed with it wx.LogMessage("Item %ld is selected"%item) `geometry` can be one of: - ``wx.LIST_NEXT_ABOVE``: Searches for an item above the specified item. - ``wx.LIST_NEXT_ALL``: Searches for subsequent item by index. - ``wx.LIST_NEXT_BELOW``: Searches for an item below the specified item. - ``wx.LIST_NEXT_LEFT``: Searches for an item to the left of the specified item. - ``wx.LIST_NEXT_RIGHT``: Searches for an item to the right of the specified item. `state` can be a bitlist of the following: - ``wx.LIST_STATE_DONTCARE``: Don't care what the state is. - ``wx.LIST_STATE_DROPHILITED``: The item indicates it is a drop target. - ``wx.LIST_STATE_FOCUSED``: The item has the focus. - ``wx.LIST_STATE_SELECTED``: The item is selected. - ``wx.LIST_STATE_CUT``: The item is selected as part of a cut and paste operation. :param `item`: :type `item`: long :param `geometry`: :type `geometry`: int :param `state`: :type `state`: int :rtype: `long` .. note:: this parameter is only supported by wxMSW currently and ignored on other platforms. .. method:: GetNextSelected(self, item) Returns subsequent selected items, or -1 when no more are selected. .. method:: GetSelectedItemCount(self) Returns the number of selected items in the list control. :rtype: `int` .. method:: GetSortIndicator(self) Returns the column that shows the sort indicator. Can return ``-1`` if there is no sort indicator currently shown. :rtype: `int` .. versionadded:: 4.1/wxWidgets-3.1.6 .. method:: GetSubItemRect(self, item, subItem, rect, code=LIST_RECT_BOUNDS) Returns the rectangle representing the size and position, in physical coordinates, of the given subitem, i.e. the part of the row `item` in the column `subItem`. This method is only meaningful when the :ref:`wx.ListCtrl` is in the report mode. If `subItem` parameter is equal to the special value ``LIST_GETSUBITEMRECT_WHOLEITEM`` the return value is the same as for :meth:`GetItemRect` . `code` can be one of ``LIST_RECT_BOUNDS`` , ``LIST_RECT_ICON`` or ``LIST_RECT_LABEL`` . Note that using ``LIST_RECT_ICON`` with any sub-item but the first one isn't very useful as only the first sub-item can have an icon in :ref:`wx.ListCtrl`. In this case, i.e. for ``subItem`` > 0, this function simply returns an empty rectangle in `rect`. :param `item`: :type `item`: long :param `subItem`: :type `subItem`: long :param `rect`: :type `rect`: wx.Rect :param `code`: :type `code`: int :rtype: `bool` .. versionadded:: 2.7.0 .. method:: GetTextColour(self) Gets the text colour of the list control. :rtype: :ref:`wx.Colour` .. method:: GetTopItem(self) Gets the index of the topmost visible item when in list or report view. :rtype: `long` .. method:: GetUpdatedAscendingSortIndicator(self, col) Returns the new value to use for sort indicator after clicking a column. This helper function can be useful in the ``EVT_LIST_COL_CLICK`` handler when it updates the sort indicator after the user clicked on a column. For example: :: def OnColClick(self, event): col = event.GetColumn() if col == -1: return # clicked outside any column. ascending = self.GetUpdatedAscendingSortIndicator(col) self.SortItems(self.MyCompareFunction, ascending) self.ShowSortIndicator(col, ascending) :param `col`: :type `col`: int :rtype: `bool` .. versionadded:: 4.1/wxWidgets-3.1.6 .. method:: GetViewRect(self) Returns the rectangle taken by all items in the control. In other words, if the controls client size were equal to the size of this rectangle, no scrollbars would be needed and no free space would be left. Note that this function only works in the icon and small icon views, not in list or report views (this is a limitation of the native Win32 control). :rtype: :ref:`wx.Rect` .. method:: HasCheckBoxes(self) Returns ``True`` if checkboxes are enabled for list items. :rtype: `bool` .. versionadded:: 4.1/wxWidgets-3.1.0 .. seealso:: :meth:`EnableCheckBoxes` .. method:: HasColumnOrderSupport(self) :rtype: `bool` .. method:: HitTest(self, point) Determines which item (if any) is at the specified point, giving details in `flags`. Returns index of the item or ``NOT_FOUND`` if no item is at the specified point. `flags` will be a combination of the following flags: - ``wx.LIST_HITTEST_ABOVE``: Above the control's client area. - ``wx.LIST_HITTEST_BELOW``: Below the control's client area. - ``wx.LIST_HITTEST_TOLEFT``: To the left of the control's client area. - ``wx.LIST_HITTEST_TORIGHT``: To the right of the control's client area. - ``wx.LIST_HITTEST_NOWHERE``: Inside the control's client area but not over an item. - ``wx.LIST_HITTEST_ONITEMICON``: Over an item's icon. - ``wx.LIST_HITTEST_ONITEMLABEL``: Over an item's text. - ``wx.LIST_HITTEST_ONITEMSTATEICON``: Over the checkbox of an item. - ``wx.LIST_HITTEST_ONITEM``: Combination of ``LIST_HITTEST_ONITEMICON`` , ``LIST_HITTEST_ONITEMLABEL`` , ``LIST_HITTEST_ONITEMSTATEICON`` . If `ptrSubItem` is not ``None`` and the :ref:`wx.ListCtrl` is in the report mode the subitem (or column) number will also be provided. This feature is only available in version 2.7.0 or higher and is currently only implemented under wxMSW and requires at least comctl32.dll of version 4.70 on the host system or the value stored in `ptrSubItem` will be always -1. To compile this feature into wxWidgets library you need to have access to commctrl.h of version 4.70 that is provided by Microsoft. .. method:: HitTestSubItem(self, point) Determines which item (if any) is at the specified point, giving details in flags. :rtype: `tuple` :returns: ( `item`, `flags`, `subitem` ) .. method:: InReportView(self) Returns ``True`` if the control is currently using ``LC_REPORT`` style. :rtype: `bool` .. method:: InsertColumn(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **InsertColumn** `(self, col, info)` For report view mode (only), inserts a column. For more details, see :meth:`SetItem` . Also see :meth:`InsertColumn` overload for a usually more convenient alternative to this method and the description of how the item width is interpreted by this method. :param `col`: :type `col`: long :param `info`: :type `info`: wx.ListItem :rtype: `long` :html:`

` **InsertColumn** `(self, col, heading, format=LIST_FORMAT_LEFT, width=LIST_AUTOSIZE)` For report view mode (only), inserts a column. Insert a new column in the list control in report view mode at the given position specifying its most common attributes. Notice that to set the image for the column you need to use :meth:`InsertColumn` overload and specify ``LIST_MASK_IMAGE`` in the item mask. :param `col`: The index where the column should be inserted. Valid indices are from 0 up to :meth:`GetColumnCount` inclusive and the latter can be used to append the new column after the last existing one. :type `col`: long :param `heading`: The string specifying the column heading. :type `heading`: string :param `format`: The flags specifying the control heading text alignment. :type `format`: int :param `width`: If positive, the width of the column in pixels. Otherwise it can be ``LIST_AUTOSIZE`` to choose the default size for the column or ``LIST_AUTOSIZE_USEHEADER`` to fit the column width to `heading` or to extend to fill all the remaining space for the last column. Notice that in case of ``LIST_AUTOSIZE`` fixed width is used as there are no items in this column to use for determining its best size yet. If you want to fit the column to its contents, use :meth:`SetColumnWidth` after adding the items with values in this column. :type `width`: int :rtype: `long` :returns: The index of the inserted column or -1 if adding it failed. :html:`

` .. method:: InsertItem(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **InsertItem** `(self, info)` Inserts an item, returning the index of the new item if successful, -1 otherwise. :param `info`: :ref:`wx.ListItem` object :type `info`: wx.ListItem :rtype: `long` :html:`

` **InsertItem** `(self, index, label)` Insert a string item. :param `index`: Index of the new item, supplied by the application :type `index`: long :param `label`: String label :type `label`: string :rtype: `long` :html:`

` **InsertItem** `(self, index, imageIndex)` Insert an image item. :param `index`: Index of the new item, supplied by the application :type `index`: long :param `imageIndex`: Index into the image list associated with this control and view style :type `imageIndex`: int :rtype: `long` :html:`

` **InsertItem** `(self, index, label, imageIndex)` Insert an image/string item. :param `index`: Index of the new item, supplied by the application :type `index`: long :param `label`: String label :type `label`: string :param `imageIndex`: Index into the image list associated with this control and view style :type `imageIndex`: int :rtype: `long` :html:`

` .. method:: IsAscendingSortIndicator(self) Returns ``True`` if the sort indicator direction is ascending, ``False`` when the direction is descending. :rtype: `bool` .. versionadded:: 4.1/wxWidgets-3.1.6 .. method:: IsEmpty(self) Returns ``True`` if the control doesn't currently contain any items. Note that the control with some columns is still considered to be empty if it has no rows. :rtype: `bool` .. versionadded:: 4.1/wxWidgets-3.1.3 .. method:: IsItemChecked(self, item) Return ``True`` if the checkbox for the given :ref:`wx.ListItem` is checked. Always returns ``False`` if checkboxes support hadn't been enabled. :param `item`: Item (zero-based) index. :type `item`: long :rtype: `bool` .. versionadded:: 4.1/wxWidgets-3.1.0 .. method:: IsSelected(self, idx) Returns ``True`` if the item is selected. .. method:: IsVirtual(self) Returns ``True`` if the control is currently in virtual report view. :rtype: `bool` .. method:: IsVisible(self, item) Check if the item is visible. An item is considered visible if at least one pixel of it is present on the screen. :param `item`: :type `item`: long :rtype: `bool` .. versionadded:: 4.1/wxWidgets-3.1.3 .. method:: OnGetItemAttr(self, item) This function may be overridden in the derived class for a control with ``LC_VIRTUAL`` style. It should return the attribute for the specified ``item`` or ``None`` to use the default appearance parameters. :ref:`wx.ListCtrl` will not delete the pointer or keep a reference of it. You can return the same :ref:`wx.ItemAttr` pointer for every :meth:`OnGetItemAttr` call. The base class version always returns ``None``. :param `item`: :type `item`: long :rtype: :ref:`wx.ItemAttr` .. seealso:: :meth:`OnGetItemImage` , :meth:`OnGetItemColumnImage` , :meth:`OnGetItemText` , :meth:`OnGetItemColumnAttr` , :meth:`OnGetItemIsChecked` .. method:: OnGetItemColumnImage(self, item, column) Override this function in the derived class for a control with ``LC_VIRTUAL`` and ``LC_REPORT`` styles in order to specify the image index for the given line and column. The base class version always calls :meth:`OnGetItemImage` for the first column, else it returns -1. :param `item`: :type `item`: long :param `column`: :type `column`: long :rtype: `int` .. seealso:: :meth:`OnGetItemText` , :meth:`OnGetItemImage` , :meth:`OnGetItemAttr` , :meth:`OnGetItemColumnAttr` .. method:: OnGetItemImage(self, item) This function must be overridden in the derived class for a control with ``LC_VIRTUAL`` style using images. If the control doesn't use images, i.e. :meth:`SetNormalImages` or :meth:`SetSmallImages` hadn't been called, it is not necessary to override it. It should return the index of the items image in the controls image list or -1 for no image. In a control with ``LC_REPORT`` style, :meth:`OnGetItemImage` only gets called for the first column of each line. The base class version always returns -1. :param `item`: :type `item`: long :rtype: `int` .. seealso:: :meth:`OnGetItemText` , :meth:`OnGetItemColumnImage` , :meth:`OnGetItemAttr` .. method:: OnGetItemIsChecked(self, item) This function **must** be overridden in the derived class for a control with ``LC_VIRTUAL`` style that uses checkboxes. It should return whether the checkbox of the specified ``item`` is checked. :param `item`: :type `item`: long :rtype: `bool` .. versionadded:: 4.1/wxWidgets-3.1.2 .. seealso:: :meth:`EnableCheckBoxes` , :meth:`OnGetItemText` .. method:: OnGetItemText(self, item, column) This function **must** be overridden in the derived class for a control with ``LC_VIRTUAL`` style. It should return the string containing the text of the given `column` for the specified ``item`` . :param `item`: :type `item`: long :param `column`: :type `column`: long :rtype: `string` .. seealso:: :meth:`SetItemCount` , :meth:`OnGetItemImage` , :meth:`OnGetItemColumnImage` , :meth:`OnGetItemAttr` .. method:: RefreshItem(self, item) Redraws the given `item`. This is only useful for the virtual list controls as without calling this function the displayed value of the item doesn't change even when the underlying data does change. :param `item`: :type `item`: long .. seealso:: :meth:`RefreshItems` .. method:: RefreshItems(self, itemFrom, itemTo) Redraws the items between `itemFrom` and `itemTo`. The starting item must be less than or equal to the ending one. Just as :meth:`RefreshItem` this is only useful for virtual list controls. :param `itemFrom`: :type `itemFrom`: long :param `itemTo`: :type `itemTo`: long .. method:: RemoveSortIndicator(self) Remove the sort indicator from the column being used as sort key. .. versionadded:: 4.1/wxWidgets-3.1.6 .. method:: ScrollList(self, dx, dy) Scrolls the list control. If in icon, small icon or report view mode, `dx` specifies the number of pixels to scroll. If in list view mode, `dx` specifies the number of columns to scroll. `dy` always specifies the number of pixels to scroll vertically. :param `dx`: :type `dx`: int :param `dy`: :type `dy`: int :rtype: `bool` .. note:: This method is currently only implemented in the Windows version. .. method:: Select(self, idx, on=1) Selects/deselects an item. .. method:: SetAlternateRowColour(self, colour) Set the alternative row background colour to a specific colour. It is recommended to call :meth:`EnableAlternateRowColours` instead of using these methods as native implementations of this control might support alternating row colours but not setting the exact colour to be used for them. As :meth:`EnableAlternateRowColours` , this method can only be used with controls having ``LC_REPORT`` and ``LC_VIRTUAL`` styles. :param `colour`: A valid alternative row background colour to enable alternating rows or invalid colour to disable them and use the same colour for all rows. :type `colour`: wx.Colour .. versionadded:: 2.9.5 .. method:: SetBackgroundColour(self, col) Sets the background colour. Note that the :meth:`wx.Window.GetBackgroundColour` function of :ref:`wx.Window` base class can be used to retrieve the current background colour. :param `col`: :type `col`: wx.Colour :rtype: `bool` .. note:: If alternate row colouring is enabled, then call :meth:`EnableAlternateRowColours` again after changing the background colour. This will update the alternate row color to match the new background colour. .. method:: SetColumn(self, col, item) Sets information about this column. See :meth:`SetItem` for more information. :param `col`: :type `col`: int :param `item`: :type `item`: wx.ListItem :rtype: `bool` .. method:: SetColumnImage(self, col, image) .. method:: SetColumnWidth(self, col, width) Sets the column width. `width` can be a width in pixels or ``LIST_AUTOSIZE`` (-1) or ``LIST_AUTOSIZE_USEHEADER`` (-2). ``LIST_AUTOSIZE`` will resize the column to the length of its longest item. ``LIST_AUTOSIZE_USEHEADER`` will resize the column to the length of the header (Win32) or 80 pixels (other platforms). In small or normal icon view, `col` must be -1, and the column width is set for all columns. :param `col`: :type `col`: int :param `width`: :type `width`: int :rtype: `bool` .. method:: SetColumnsOrder(self, orders) Changes the order in which the columns are shown. The `orders` array must have the same number elements as the number of columns and contain each position exactly once. Its n-th element contains the index of the column to be shown in n-th position, so for a control with three columns passing an array with elements 2, 0 and 1 results in the third column being displayed first, the first one next and the second one last. :param `orders`: :type `orders`: list of integers :rtype: `bool` .. note:: This function makes sense for report view only and currently is only implemented in the wxMSW port. Use ``HAS_LISTCTRL_COLUMN_ORDER`` to guard uses of this function so that they will start working under the other platforms when support for the column reordering is added there. .. seealso:: :meth:`GetColumnsOrder` .. method:: SetHeaderAttr(self, attr) Change the font and the colours used for the list control header. This method can be used to change the appearance of the header shown by the control in report mode (unless ``LC_NO_HEADER`` style is used). Currently it is implemented only for wxMSW and does nothing in the other ports. :param `attr`: The object containing the font and text and background colours to use. It may be default, i.e. not specify any custom font nor colours, to reset any previously set custom attribute. :type `attr`: wx.ItemAttr :rtype: `bool` :returns: ``True`` if the attributes have been updated or ``False`` if this is not supported by the current platform. .. versionadded:: 4.1/wxWidgets-3.1.1 .. method:: SetImageList(self, imageList, which) Sets the image list associated with the control. Not that it is recommended to use :meth:`SetNormalImages` or :meth:`SetSmallImages` instead of this function in the new code. `which` must be one of ``IMAGE_LIST_NORMAL`` , ``IMAGE_LIST_SMALL`` , ``IMAGE_LIST_STATE`` (support for the last one is unimplemented). This method does not take ownership of the image list, you have to delete it yourself. Note that, unlike for most of the other methods of this class, it is possible to call this function before the corresponding window is created, i.e. do it in a constructor of a class derived from :ref:`wx.ListCtrl` before calling :meth:`Create` . :param `imageList`: :type `imageList`: wx.ImageList :param `which`: :type `which`: int .. seealso:: :meth:`AssignImageList` .. method:: SetItem(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **SetItem** `(self, info)` Sets the data of an item. Using the :ref:`wx.ListItem`'s mask and state mask, you can change only selected attributes of a :ref:`wx.ListCtrl` item. :param `info`: :type `info`: wx.ListItem :rtype: `bool` :returns: ``True`` if the item was successfully updated or ``False`` if the update failed for some reason (e.g. an invalid item index). :html:`

` **SetItem** `(self, index, column, label, imageId=-1)` Sets an item string field at a particular column. :param `index`: :type `index`: long :param `column`: :type `column`: int :param `label`: :type `label`: string :param `imageId`: :type `imageId`: int :rtype: `bool` :returns: ``True`` if the item was successfully updated or ``False`` if the update failed for some reason (e.g. an invalid item index). :html:`

` .. method:: SetItemBackgroundColour(self, item, col) Sets the background colour for this item. This function only works in report view mode. The colour can be retrieved using :meth:`GetItemBackgroundColour` . :param `item`: :type `item`: long :param `col`: :type `col`: wx.Colour .. method:: SetItemColumnImage(self, item, column, image) Sets the image associated with the item. In report view, you can specify the column. The image is an index into the image list associated with the list control. :param `item`: :type `item`: long :param `column`: :type `column`: long :param `image`: :type `image`: int :rtype: `bool` .. method:: SetItemCount(self, count) This method can only be used with virtual list controls. It is used to indicate to the control the number of items it contains. After calling it, the main program should be ready to handle calls to various item callbacks (such as :meth:`wx.ListCtrl.OnGetItemText` ) for all items in the range from 0 to `count`. Notice that the control is not necessarily redrawn after this call as it may be undesirable if an item which is not visible on the screen anyhow was added to or removed from a control displaying many items, if you do need to refresh the display you can just call :meth:`Refresh` manually. :param `count`: :type `count`: long .. method:: SetItemData(self, item, data) Associates application-defined data with this item. Notice that this function cannot be used to associate pointers with the control items, use :meth:`SetItemPtrData` instead. :param `item`: :type `item`: long :param `data`: :type `data`: long :rtype: `bool` .. method:: SetItemFont(self, item, font) Sets the item's font. :param `item`: :type `item`: long :param `font`: :type `font`: wx.Font .. method:: SetItemImage(self, item, image, selImage=-1) Sets the unselected and selected images associated with the item. The images are indices into the image list associated with the list control. :param `item`: :type `item`: long :param `image`: :type `image`: int :param `selImage`: :type `selImage`: int :rtype: `bool` .. method:: SetItemPosition(self, item, pos) Sets the position of the item, in icon or small icon view. Windows only. :param `item`: :type `item`: long :param `pos`: :type `pos`: wx.Point :rtype: `bool` .. method:: SetItemState(self, item, state, stateMask) Sets the item state. The `stateMask` is a combination of ``LIST_STATE_XXX`` constants described in :ref:`wx.ListItem` documentation. For each of the bits specified in `stateMask`, the corresponding state is set or cleared depending on whether `state` argument contains the same bit or not. So to select an item you can use :: listCtrl.SetItemState(item, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED) while to deselect it you should use :: listCtrl.SetItemState(item, 0, wx.LIST_STATE_SELECTED) Consider using :ref:`wx.ListView` if possible to avoid dealing with this error-prone and confusing method. Also notice that contrary to the usual rule that only user actions generate events, this method does generate wxEVT_LIST_ITEM_SELECTED event when it is used to select an item. :param `item`: :type `item`: long :param `state`: :type `state`: long :param `stateMask`: :type `stateMask`: long :rtype: `bool` .. method:: SetItemText(self, item, text) Sets the item text for this item. :param `item`: :type `item`: long :param `text`: :type `text`: string .. method:: SetItemTextColour(self, item, col) Sets the colour for this item. This function only works in report view. The colour can be retrieved using :meth:`GetItemTextColour` . :param `item`: :type `item`: long :param `col`: :type `col`: wx.Colour .. method:: SetNormalImages(self, images) Sets the images to use when showing large, normal icons in this control. These images are used by the items when the list control is in ``wx.LC_ICON`` mode, in all the other modes the images set by :meth:`SetSmallImages` are used. This function should be preferred to calling :meth:`SetImageList` or :meth:`AssignImageList` with ``IMAGE_LIST_NORMAL`` argument in the new code, as using :ref:`wx.BitmapBundle` makes it possible to specify multiple versions of the icons, allowing the control to choose the right one for the current ``DPI`` scaling. :param `images`: :type `images`: Vector .. versionadded:: 4.1/wxWidgets-3.1.6 .. method:: SetSingleStyle(self, style, add=True) Adds or removes a single window style. :param `style`: :type `style`: long :param `add`: :type `add`: bool .. method:: SetSmallImages(self, images) Sets the images to use when showing small icons in this control. These images are used by the items when the list control is in ``wx.LC_SMALL_ICON`` or ``wx.LC_REPORT`` mode, use :meth:`SetNormalImages` for the icons used in ``wx.LC_ICON`` mode. This function should be preferred to calling :meth:`SetImageList` or :meth:`AssignImageList` with ``IMAGE_LIST_SMALL`` argument in the new code, as using :ref:`wx.BitmapBundle` makes it possible to specify multiple versions of the icons, allowing the control to choose the right one for the current ``DPI`` scaling. :param `images`: :type `images`: Vector .. versionadded:: 4.1/wxWidgets-3.1.6 .. method:: SetTextColour(self, col) Sets the text colour of the list control. :param `col`: :type `col`: wx.Colour .. method:: SetWindowStyleFlag(self, style) Sets the whole window style, deleting all items. :param `style`: :type `style`: long .. method:: ShowSortIndicator(self, col, ascending=True) Show the sort indicator of a specific column in a specific direction. Sort indicators are only shown in report view and in the native wxMSW version override any column icon, i.e. if the sort indicator is shown for a column, no (other) icon is shown. This function should typically be called from ``EVT_LIST_COL_CLICK`` handler. :param `col`: The column to set the sort indicator for. If ``-1`` is given, then the currently shown sort indicator will be removed. :type `col`: int :param `ascending`: If ``True`` or ``False`` show the sort indicator corresponding to ascending or descending sort order respectively. :type `ascending`: bool .. versionadded:: 4.1/wxWidgets-3.1.6 .. note:: This does not actually sort the list, use :meth:`SortItems` for this. .. method:: SortItems(self, fnSortCallBack) Call this function to sort the items in the list control. Sorting is done using the specified `fnSortCallBack` function. This function must have the following prototype: :: def ListCompareFunction(self, item1, item2): pass It is called each time when the two items must be compared and should return 0 if the items are equal, negative value if the first item is less than the second one and positive value if the first one is greater than the second one (the same convention as used by ``qsort(3)`` ). The parameter `item1` is the client data associated with the first item (**NOT** the index). The parameter `item2` is the client data associated with the second item (**NOT** the index). The parameter `data` is the value passed to :meth:`SortItems` itself. Notice that the control may only be sorted on client data associated with the items, so you must use SetItemData if you want to be able to sort the items in the control. Please see the :ref:`List Control Sample ` for an example of using this function. .. attribute:: AlternateRowColour See :meth:`~wx.ListCtrl.GetAlternateRowColour` and :meth:`~wx.ListCtrl.SetAlternateRowColour` .. attribute:: Column See :meth:`~wx.ListCtrl.GetColumn` and :meth:`~wx.ListCtrl.SetColumn` .. attribute:: ColumnCount See :meth:`~wx.ListCtrl.GetColumnCount` .. attribute:: ColumnsOrder See :meth:`~wx.ListCtrl.GetColumnsOrder` and :meth:`~wx.ListCtrl.SetColumnsOrder` .. attribute:: CountPerPage See :meth:`~wx.ListCtrl.GetCountPerPage` .. attribute:: EditControl See :meth:`~wx.ListCtrl.GetEditControl` .. attribute:: FocusedItem See :meth:`~wx.ListCtrl.GetFocusedItem` .. attribute:: Item See :meth:`~wx.ListCtrl.GetItem` and :meth:`~wx.ListCtrl.SetItem` .. attribute:: ItemCount See :meth:`~wx.ListCtrl.GetItemCount` and :meth:`~wx.ListCtrl.SetItemCount` .. attribute:: ItemPosition See :meth:`~wx.ListCtrl.GetItemPosition` and :meth:`~wx.ListCtrl.SetItemPosition` .. attribute:: ItemRect See :meth:`~wx.ListCtrl.GetItemRect` .. attribute:: ItemSpacing See :meth:`~wx.ListCtrl.GetItemSpacing` .. attribute:: MainWindow See :meth:`~wx.ListCtrl.GetMainWindow` .. attribute:: SelectedItemCount See :meth:`~wx.ListCtrl.GetSelectedItemCount` .. attribute:: SortIndicator See :meth:`~wx.ListCtrl.GetSortIndicator` .. attribute:: TextColour See :meth:`~wx.ListCtrl.GetTextColour` and :meth:`~wx.ListCtrl.SetTextColour` .. attribute:: TopItem See :meth:`~wx.ListCtrl.GetTopItem` .. attribute:: ViewRect See :meth:`~wx.ListCtrl.GetViewRect`