**************** wx.ItemContainer **************** Inheritance diagram for `wx.ItemContainer`: | .. inheritance-diagram:: wx.ItemContainer | Description =========== The `wx.ItemContainer` class defines an interface which is implemented by all controls which have string subitems, each of which may be selected, such as `wx.ListBox `_ and `wx.CheckListBox `_ derived from it, `wx.Choice `_ and `wx.ComboBox `_, which implements an extended interface deriving from this one. It defines the methods for accessing the control's items and although each of the derived classes implements them differently, they still all conform to the same interface. The items in a `wx.ItemContainer` have (non empty) string labels and, optionally, client data associated with them. Derived From ^^^^^^^^^^^^^ * `wx.Object `_ Known Subclasses ^^^^^^^^^^^^^^^^ `wx.CheckListBox `_, `wx.Choice `_, `wx.ComboBox `_, `wx.DirFilterListCtrl`, `wx.ListBox `_ Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `Append <#Append>`_ * `AppendItems <#AppendItems>`_ * `Clear <#Clear>`_ * `Delete <#Delete>`_ * `FindString <#FindString>`_ * `GetClientData <#GetClientData>`_ * `GetCount <#GetCount>`_ * `GetItems <#GetItems>`_ * `GetSelection <#GetSelection>`_ * `GetString <#GetString>`_ * `GetStrings <#GetStrings>`_ * `GetStringSelection <#GetStringSelection>`_ * `Insert <#Insert>`_ * `IsEmpty <#IsEmpty>`_ * `Select <#Select>`_ * `SetClientData <#SetClientData>`_ * `SetItems <#SetItems>`_ * `SetSelection <#SetSelection>`_ * `SetString <#SetString>`_ * `SetStringSelection <#SetStringSelection>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `Count <#Count>`_ * `Items <#Items>`_ * `Selection <#Selection>`_ * `Strings <#Strings>`_ * `StringSelection <#StringSelection>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__() `No docstrings found for this method.` -------- .. method:: Append(item, clientData=None) Adds the item to the control, associating the given data with the item if not ``None``. The return value is the index of the newly added item which may be different from the last one if the control is sorted (e.g. has ``wx.LB_SORT`` or ``wx.CB_SORT`` style). **Parameters:** * `item` (string): the item name. * `clientData` (PyObject): the associated client data. | **Returns:** `int` ---------- .. method:: AppendItems(items) Append several items at once to the control. **Parameters:** * `items` (list of strings): the item names. .. note:: Notice that calling this method may be much faster than appending the items one by one if you need to add a lot of items. ---------- .. method:: Clear() Removes all items from the control. `Clear()` also deletes the client data of the existing items if it is owned by the control. .. seealso:: `Delete <#Delete>`_ ---------- .. method:: Delete(n) Deletes the item at the zero-based index `n` from the control. **Parameters:** * `n` (int): the item index. .. note:: Note that it is an error (signalled by a `wx.PyAssertionError` exception if enabled) to remove an item with the index negative or greater or equal than the number of items in the control. .. seealso:: `Clear <#Clear>`_ ---------- .. method:: FindString(s) Finds an item whose label matches the given string. Returns the zero-based position of the item, or ``wx.NOT_FOUND`` if the string was not found. **Parameters:** * `s` (string): the item label. | **Returns:** `int` ---------- .. method:: GetClientData(n) Returns a pointer to the client data associated with the given item (if any). It is an error to call this function for a control which doesn't have untyped client data at all although it is ok to call it even if the given item doesn't have any client data associated with it (but other items do). **Parameters:** * `n` (int): the item index. | **Returns:** `PyObject` ---------- .. method:: GetCount() Returns the number of items in the control. | **Returns:** `int` .. seealso:: `IsEmpty <#IsEmpty>`_ ---------- .. method:: GetItems() Returns a list of items in the control. | **Returns:** `list of strings` .. seealso:: `SetItems <#SetItems>`_ ---------- .. method:: GetSelection() Returns the index of the selected item or ``wx.NOT_FOUND`` if no item is selected. | **Returns:** `int` .. note:: This method can be used with single selection list boxes only, you should use `wx.ListBox.GetSelections `_ for the list boxes with ``wx.LB_MULTIPLE`` style. .. seealso:: `SetSelection <#SetSelection>`_ ---------- .. method:: GetString(n) Returns the item label at the zero-based index `n` from the control. **Parameters:** * `n` (int): the item index. | **Returns:** `string` ---------- .. method:: GetStrings() Returns the array of the labels of all items in the control. | **Returns:** `list of strings` ---------- .. method:: GetStringSelection() Returns the label of the selected item or an empty string if no item is selected. | **Returns:** `string` ---------- .. method:: Insert(item, pos, clientData=None) Inserts the item into the list before `pos`, associating the given client data pointer with the item. Not valid for ``wx.LB_SORT`` or ``wx.CB_SORT`` styles, use `Append <#Append>`_ instead. **Parameters:** * `item` (string): the item name. * `pos` (int): the item position. * `clientData` (PyObject): the associated client data. | **Returns:** `int` ---------- .. method:: IsEmpty() Returns ``True`` if the control is empty or ``False`` if it has some items. | **Returns:** `bool` .. seealso:: `GetCount <#GetCount>`_ ---------- .. method:: Select(n) This is the same as `SetSelection <#SetSelection>`_ and exists only because it is slightly more natural for controls which support multiple selection **Parameters:** * `n` (int): the item index. ---------- .. method:: SetClientData(n, data) Associates the given client data pointer with the given item. **Parameters:** * `n` (int): the item index. * `data` (PyObject): The client data to associate with the item. .. note:: Note that it is an error to call this function if any typed client data pointers had been associated with the control items before. ---------- .. method:: SetItems(items) Clear and set the strings in the control from a list. **Parameters:** * `items` (list of strings): the items to set. .. seealso:: `GetItems <#GetItems>`_ ----------- .. method:: SetSelection(n) Sets the selection to the given item `n` or removes the selection entirely if `n` == ``wx.NOT_FOUND``. **Parameters:** * `n` (int): The string position to select, starting from zero. .. note:: Note that this does not cause any command events to be emitted nor does it deselect any other items in the controls which support multiple selections. .. seealso:: `SetString <#SetString>`_, `SetStringSelection <#SetStringSelection>`_ ----------- .. method:: SetString(n, string) Sets the label for the given item. **Parameters:** * `n` (int): The string position, starting from zero. * `string` (string): The string label. ----------- .. method:: SetStringSelection(string) Selects the item with the specified string in the control. This doesn't cause any command events being emitted. Returns ``True`` if the specified string has been selected, ``False`` if it wasn't found in the control. **Parameters:** * `string` (string): The string label to select. | **Returns:** `bool` .. seealso:: `SetSelection <#SetSelection>`_, `GetStringSelection <#GetStringSelection>`_ -------- Properties ^^^^^^^^^^ .. attribute:: Count See `GetCount <#GetCount>`_ .. attribute:: Items See `GetItems <#GetItems>`_ and `SetItems <#SetItems>`_ .. attribute:: Selection See `GetSelection <#GetSelection>`_ and `SetSelection <#SetSelection>`_ .. attribute:: Strings See `GetStrings <#GetStrings>`_ .. attribute:: StringSelection See `GetStringSelection <#GetStringSelection>`_ and `SetStringSelection <#SetStringSelection>`_