wx.ItemContainerImmutable¶
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 wx.ItemContainerImmutable which omits all methods adding/removing items and is used by wx.RadioBox and wx.ItemContainer itself.
Note that this is not a control, it’s a mixin interface that classes have to derive from in addition to wx.Control or wx.Window.
Examples: wx.ListBox, wx.CheckListBox, wx.Choice and wx.ComboBox (which implements an extended interface deriving from this one)
See also
Class Hierarchy¶
Known Subclasses¶
Methods Summary¶
Constructor. |
|
Finds an item whose label matches the given string. |
|
Returns the number of items in the control. |
|
Returns the index of the selected item or |
|
Returns the label of the item with the given index. |
|
Returns the label of the selected item or an empty string if no item is selected. |
|
Returns the array of the labels of all items in the control. |
|
Returns |
|
This is the same as |
|
Sets the selection to the given item n or removes the selection entirely if n == |
|
Sets the label for the given item. |
|
Selects the item with the specified string in the control. |
Properties Summary¶
See |
|
See |
|
See |
|
See |
Class API¶
- class wx.ItemContainerImmutable(object)¶
Possible constructors:
ItemContainerImmutable() -> None
ItemContainer defines an interface which is implemented by all controls which have string subitems each of which may be selected.
Methods¶
- __init__(self)¶
Constructor.
- Return type:
None
- FindString(self, string, caseSensitive=False)¶
Finds an item whose label matches the given string.
- Parameters:
string (string) – String to find.
caseSensitive (bool) – Whether search is case sensitive (default is not).
- Return type:
int
- Returns:
The zero-based position of the item, or
wx.NOT_FOUNDif the string was not found.
- GetSelection(self)¶
Returns the index of the selected item or
NOT_FOUNDif no item is selected.- Return type:
int
- Returns:
The position of the current selection.
See also
- 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
GetCount, otherwise an assert is triggered. Notably, this function can’t be called if the control is empty.- Parameters:
n (int) – The zero-based index.
- Return type:
str
- Returns:
The label of the item.
- GetStringSelection(self)¶
Returns the label of the selected item or an empty string if no item is selected.
- Return type:
str
See also
- GetStrings(self)¶
Returns the array of the labels of all items in the control.
- Return type:
List[str]
- IsEmpty(self)¶
Returns
Trueif the control is empty orFalseif it has some items.- Return type:
bool
See also
- Select(self, n)¶
This is the same as
SetSelectionand exists only because it is slightly more natural for controls which support multiple selection.- Parameters:
n (int)
- Return type:
None
- 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.
- Parameters:
n (int) – The string position to select, starting from zero.
- Return type:
None
See also
- SetString(self, n, string)¶
Sets the label for the given item.
- Parameters:
n (int) – The zero-based item index.
string (string) – The label to set.
- Return type:
None
- 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.
- Parameters:
string (string) – The string to select.
- Return type:
bool
- Returns:
Trueif the specified string has been selected,Falseif it wasn’t found in the control.
Properties¶
- Selection¶
See
GetSelectionandSetSelection
- StringSelection¶
See
GetStringSelectionandSetStringSelection
- Strings¶
See
GetStrings