.. include:: headings.inc .. _CheckListBox: ========================================================================================================================================== |phoenix_title| **CheckListBox** ========================================================================================================================================== A :ref:`CheckListBox` is like a :ref:`ListBox`, but allows items to be checked or unchecked. When using this class under Windows wxWidgets must be compiled with ``USE_OWNER_DRAWN`` set to 1. .. _CheckListBox-events: |events| Events Emitted by this Class ===================================== Handlers bound for the following event types will receive a :ref:`CommandEvent` parameter. - EVT_CHECKLISTBOX: Process a ``wxEVT_COMMAND_CHECKLISTBOX_TOGGLED`` event, when an item in the check list box is checked or unchecked. :meth:`CommandEvent.GetInt` will contain the index of the item that was checked or unchecked. :meth:`CommandEvent.IsChecked` is not valid! Use :meth:`CheckListBox.IsChecked` instead. .. seealso:: :ref:`ListBox`, :ref:`Choice`, :ref:`ComboBox`, :ref:`ListCtrl`, :ref:`CommandEvent` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **CheckListBox** .. raw:: html

Inheritance diagram of CheckListBox

| |appearance| Control Appearance =============================== | .. figure:: _static/images/widgets/fullsize/wxmsw/checklistbox.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: _static/images/widgets/fullsize/wxmac/checklistbox.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: _static/images/widgets/fullsize/wxgtk/checklistbox.png :alt: wxGTK :figclass: floatcenter **wxGTK** | |sub_classes| Known Subclasses ============================== `RearrangeList` | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~CheckListBox.__init__` Constructor, creating and showing a list box. :meth:`~CheckListBox.Check` Checks the given item. :meth:`~CheckListBox.Create` Creates the listbox for two-step construction. :meth:`~CheckListBox.GetChecked` GetChecked() :meth:`~CheckListBox.GetCheckedStrings` GetCheckedStrings() :meth:`~CheckListBox.IsChecked` Returns ``True`` if the given item is checked, ``False`` otherwise. :meth:`~CheckListBox.SetChecked` SetChecked(indexes) :meth:`~CheckListBox.SetCheckedStrings` SetCheckedStrings(strings) ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~CheckListBox.Checked` See :meth:`~CheckListBox.GetChecked` and :meth:`~CheckListBox.SetChecked` :attr:`~CheckListBox.CheckedStrings` See :meth:`~CheckListBox.GetCheckedStrings` and :meth:`~CheckListBox.SetCheckedStrings` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: CheckListBox(ListBox) A CheckListBox is like a ListBox, but allows items to be checked or unchecked. **Possible constructors**:: CheckListBox(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, choices=[], style=0, validator=DefaultValidator, name="listBox") CheckListBox() .. method:: __init__(self, *args, **kw) |overload| **Overloaded Implementations**: **~~~** **__init__** `(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, choices=[], style=0, validator=DefaultValidator, name="listBox")` Constructor, creating and showing a list box. :param `parent`: Parent window. Must not be ``None``. :type `parent`: Window :param `id`: Window identifier. The value ``ID_ANY`` indicates a default value. :type `id`: int :param `pos`: Window position. :type `pos`: Point :param `size`: Window size. If DefaultSize is specified then the window is sized appropriately. :type `size`: Size :param `choices`: An array of strings with which to initialise the control. :type `choices`: list of strings :param `style`: Window style. See :ref:`CheckListBox`. :type `style`: long :param `validator`: Window validator. :type `validator`: Validator :param `name`: Window name. :type `name`: string **~~~** **__init__** `(self)` Default constructor. **~~~** .. method:: Check(self, item, check=True) Checks the given item. Note that calling this method does not result in a ``wxEVT_COMMAND_CHECKLISTBOX_TOGGLE`` event being emitted. :param `item`: Index of item to check. :type `item`: int :param `check`: ``True`` if the item is to be checked, ``False`` otherwise. :type `check`: bool .. method:: Create(self, *args, **kw) Creates the listbox for two-step construction. See :meth:`ListBox` for further details. .. method:: GetChecked(self) GetChecked() Return a sequence of integers corresponding to the checked items in the control, based on `IsChecked`. .. method:: GetCheckedStrings(self) GetCheckedStrings() Return a tuple of strings corresponding to the checked items of the control, based on `GetChecked`. .. method:: IsChecked(self, item) Returns ``True`` if the given item is checked, ``False`` otherwise. :param `item`: Index of item whose check status is to be returned. :type `item`: int :rtype: `bool` .. method:: SetChecked(self, indexes) SetChecked(indexes) Sets the checked state of items if the index of the item is found in the indexes sequence. .. method:: SetCheckedStrings(self, strings) SetCheckedStrings(strings) Sets the checked state of items if the item's string is found in the strings sequence. .. attribute:: Checked See :meth:`~CheckListBox.GetChecked` and :meth:`~CheckListBox.SetChecked` .. attribute:: CheckedStrings See :meth:`~CheckListBox.GetCheckedStrings` and :meth:`~CheckListBox.SetCheckedStrings`