.. 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.ItemContainerImmutable: ========================================================================================================================================== |phoenix_title| **wx.ItemContainerImmutable** ========================================================================================================================================== :ref:`wx.ItemContainer` defines an interface which is implemented by all controls which have string subitems each of which may be selected. It is decomposed in :ref:`wx.ItemContainerImmutable` which omits all methods adding/removing items and is used by :ref:`wx.RadioBox` and :ref:`wx.ItemContainer` itself. Note that this is not a control, it's a mixin interface that classes have to derive from in addition to :ref:`wx.Control` or :ref:`wx.Window`. Examples: :ref:`wx.ListBox`, :ref:`wx.CheckListBox`, :ref:`wx.Choice` and :ref:`wx.ComboBox` (which implements an extended interface deriving from this one) .. seealso:: :ref:`wx.ControlWithItems`, :ref:`wx.ItemContainer` | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class ItemContainerImmutable:
| |sub_classes| Known Subclasses ============================== :ref:`wx.ItemContainer`, :ref:`wx.RadioBox` | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.ItemContainerImmutable.__init__` Constructor. :meth:`~wx.ItemContainerImmutable.FindString` Finds an item whose label matches the given string. :meth:`~wx.ItemContainerImmutable.GetCount` Returns the number of items in the control. :meth:`~wx.ItemContainerImmutable.GetSelection` Returns the index of the selected item or ``NOT_FOUND`` if no item is selected. :meth:`~wx.ItemContainerImmutable.GetString` Returns the label of the item with the given index. :meth:`~wx.ItemContainerImmutable.GetStringSelection` Returns the label of the selected item or an empty string if no item is selected. :meth:`~wx.ItemContainerImmutable.GetStrings` Returns the array of the labels of all items in the control. :meth:`~wx.ItemContainerImmutable.IsEmpty` Returns ``True`` if the control is empty or ``False`` if it has some items. :meth:`~wx.ItemContainerImmutable.Select` This is the same as :meth:`~ItemContainerImmutable.SetSelection` and exists only because it is slightly more natural for controls which support multiple selection. :meth:`~wx.ItemContainerImmutable.SetSelection` Sets the selection to the given item `n` or removes the selection entirely if `n` == ``NOT_FOUND`` . :meth:`~wx.ItemContainerImmutable.SetString` Sets the label for the given item. :meth:`~wx.ItemContainerImmutable.SetStringSelection` Selects the item with the specified string in the control. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~wx.ItemContainerImmutable.Count` See :meth:`~wx.ItemContainerImmutable.GetCount` :attr:`~wx.ItemContainerImmutable.Selection` See :meth:`~wx.ItemContainerImmutable.GetSelection` and :meth:`~wx.ItemContainerImmutable.SetSelection` :attr:`~wx.ItemContainerImmutable.StringSelection` See :meth:`~wx.ItemContainerImmutable.GetStringSelection` and :meth:`~wx.ItemContainerImmutable.SetStringSelection` :attr:`~wx.ItemContainerImmutable.Strings` See :meth:`~wx.ItemContainerImmutable.GetStrings` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: wx.ItemContainerImmutable(object) **Possible constructors**:: ItemContainerImmutable() ItemContainer defines an interface which is implemented by all controls which have string subitems each of which may be selected. .. method:: __init__(self) Constructor. .. method:: FindString(self, string, caseSensitive=False) Finds an item whose label matches the given string. :param `string`: String to find. :type `string`: string :param `caseSensitive`: Whether search is case sensitive (default is not). :type `caseSensitive`: bool :rtype: `int` :returns: The zero-based position of the item, or ``wx.NOT_FOUND`` if the string was not found. .. method:: GetCount(self) Returns the number of items in the control. :rtype: `int` .. seealso:: :meth:`IsEmpty` .. method:: GetSelection(self) Returns the index of the selected item or ``NOT_FOUND`` if no item is selected. :rtype: `int` :returns: The position of the current selection. .. seealso:: :meth:`SetSelection` , :meth:`GetStringSelection` .. method:: GetString(self, n) Returns the label of the item with the given index. The index must be valid, i.e. less than the value returned by :meth:`GetCount` , otherwise an assert is triggered. Notably, this function can't be called if the control is empty. :param `n`: The zero-based index. :type `n`: int :rtype: `string` :returns: The label of the item. .. method:: GetStringSelection(self) Returns the label of the selected item or an empty string if no item is selected. :rtype: `string` .. seealso:: :meth:`GetSelection` .. method:: GetStrings(self) Returns the array of the labels of all items in the control. :rtype: `list of strings` .. method:: IsEmpty(self) Returns ``True`` if the control is empty or ``False`` if it has some items. :rtype: `bool` .. seealso:: :meth:`GetCount` .. method:: Select(self, n) This is the same as :meth:`SetSelection` and exists only because it is slightly more natural for controls which support multiple selection. :param `n`: :type `n`: int .. method:: SetSelection(self, n) Sets the selection to the given item `n` or removes the selection entirely if `n` == ``NOT_FOUND`` . 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. :param `n`: The string position to select, starting from zero. :type `n`: int .. seealso:: :meth:`SetString` , :meth:`SetStringSelection` .. method:: SetString(self, n, string) Sets the label for the given item. :param `n`: The zero-based item index. :type `n`: int :param `string`: The label to set. :type `string`: string .. method:: SetStringSelection(self, string) Selects the item with the specified string in the control. This method doesn't cause any command events to be emitted. Notice that this method is case-insensitive, i.e. the string is compared with all the elements of the control case-insensitively and the first matching entry is selected, even if it doesn't have exactly the same case as this string and there is an exact match afterwards. :param `string`: The string to select. :type `string`: string :rtype: `bool` :returns: ``True`` if the specified string has been selected, ``False`` if it wasn't found in the control. .. attribute:: Count See :meth:`~wx.ItemContainerImmutable.GetCount` .. attribute:: Selection See :meth:`~wx.ItemContainerImmutable.GetSelection` and :meth:`~wx.ItemContainerImmutable.SetSelection` .. attribute:: StringSelection See :meth:`~wx.ItemContainerImmutable.GetStringSelection` and :meth:`~wx.ItemContainerImmutable.SetStringSelection` .. attribute:: Strings See :meth:`~wx.ItemContainerImmutable.GetStrings`