.. include:: headings.inc .. _ItemContainerImmutable: ========================================================================================================================================== |phoenix_title| **ItemContainerImmutable** ========================================================================================================================================== :ref:`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:`ItemContainerImmutable` which omits all methods adding/removing items and is used by :ref:`RadioBox` and :ref:`ItemContainer` itself. Note that this is not a control, it's a mixin interface that classes have to derive from in addition to :ref:`Control` or :ref:`Window`. Examples: :ref:`ListBox`, :ref:`CheckListBox`, :ref:`Choice` and :ref:`ComboBox` (which implements an extended interface deriving from this one) .. seealso:: :ref:`ControlWithItems`, :ref:`ItemContainer` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **ItemContainerImmutable** .. raw:: html

Inheritance diagram of ItemContainerImmutable

| |sub_classes| Known Subclasses ============================== :ref:`ItemContainer`, :ref:`RadioBox` | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~ItemContainerImmutable.__init__` Constructor. :meth:`~ItemContainerImmutable.FindString` Finds an item whose label matches the given string. :meth:`~ItemContainerImmutable.GetCount` Returns the number of items in the control. :meth:`~ItemContainerImmutable.GetSelection` Returns the index of the selected item or ``NOT_FOUND`` if no item is selected. :meth:`~ItemContainerImmutable.GetString` Returns the label of the item with the given index. :meth:`~ItemContainerImmutable.GetStringSelection` Returns the label of the selected item or an empty string if no item is selected. :meth:`~ItemContainerImmutable.GetStrings` Returns the array of the labels of all items in the control. :meth:`~ItemContainerImmutable.IsEmpty` Returns ``True`` if the control is empty or ``False`` if it has some items. :meth:`~ItemContainerImmutable.Select` This is the same as :meth:`SetSelection` and exists only because it is slightly more natural for controls which support multiple selection. :meth:`~ItemContainerImmutable.SetSelection` Sets the selection to the given item `n` or removes the selection entirely if `n` == ``NOT_FOUND`` . :meth:`~ItemContainerImmutable.SetString` Sets the label for the given item. :meth:`~ItemContainerImmutable.SetStringSelection` Selects the item with the specified string in the control. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~ItemContainerImmutable.Count` See :meth:`~ItemContainerImmutable.GetCount` :attr:`~ItemContainerImmutable.Selection` See :meth:`~ItemContainerImmutable.GetSelection` and :meth:`~ItemContainerImmutable.SetSelection` :attr:`~ItemContainerImmutable.StringSelection` See :meth:`~ItemContainerImmutable.GetStringSelection` and :meth:`~ItemContainerImmutable.SetStringSelection` :attr:`~ItemContainerImmutable.Strings` See :meth:`~ItemContainerImmutable.GetStrings` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: ItemContainerImmutable(object) ItemContainer defines an interface which is implemented by all controls which have string subitems each of which may be selected. **Possible constructors**:: ItemContainerImmutable() .. 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 ``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. .. note:: This method can be used with single selection list boxes only, you should use :meth:`ListBox.GetSelections` for the list boxes with ``LB_MULTIPLE`` style. .. seealso:: :meth:`SetSelection` , :meth:`GetStringSelection` .. method:: GetString(self, n) Returns the label of the item with the given index. :param `n`: The zero-based index. :type `n`: int :rtype: `string` :returns: The label of the item or an empty string if the position was invalid. .. 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:`~ItemContainerImmutable.GetCount` .. attribute:: Selection See :meth:`~ItemContainerImmutable.GetSelection` and :meth:`~ItemContainerImmutable.SetSelection` .. attribute:: StringSelection See :meth:`~ItemContainerImmutable.GetStringSelection` and :meth:`~ItemContainerImmutable.SetStringSelection` .. attribute:: Strings See :meth:`~ItemContainerImmutable.GetStrings`