wx.ItemContainer

Inheritance diagram for 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

Known Subclasses

wx.CheckListBox, wx.Choice, wx.ComboBox, wx.DirFilterListCtrl, wx.ListBox

Class API

Methods

__init__()
No docstrings found for this 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


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.


Clear()

Removes all items from the control.

Clear() also deletes the client data of the existing items if it is owned by the control.

See also

Delete


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.

See also

Clear


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


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


GetCount()

Returns the number of items in the control.


Returns:

int

See also

IsEmpty


GetItems()

Returns a list of items in the control.


Returns:

list of strings

See also

SetItems


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.

See also

SetSelection


GetString(n)

Returns the item label at the zero-based index n from the control.

Parameters:

  • n (int): the item index.

Returns:

string


GetStrings()

Returns the array of the labels of all items in the control.


Returns:

list of strings


GetStringSelection()

Returns the label of the selected item or an empty string if no item is selected.


Returns:

string


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 instead.

Parameters:

  • item (string): the item name.
  • pos (int): the item position.
  • clientData (PyObject): the associated client data.

Returns:

int


IsEmpty()

Returns True if the control is empty or False if it has some items.


Returns:

bool

See also

GetCount


Select(n)

This is the same as SetSelection and exists only because it is slightly more natural for controls which support multiple selection

Parameters:

  • n (int): the item index.

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.


SetItems(items)

Clear and set the strings in the control from a list.

Parameters:

  • items (list of strings): the items to set.

See also

GetItems


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.


SetString(n, string)

Sets the label for the given item.

Parameters:

  • n (int): The string position, starting from zero.
  • string (string): The string label.

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


Properties

Count
See GetCount
Items
See GetItems and SetItems
Selection
See GetSelection and SetSelection
Strings
See GetStrings
StringSelection
See GetStringSelection and SetStringSelection