A choice item is used to select one of a list of strings.
Unlike a ListBox, only the selection is visible until the user pulls down the menu of choices.
Handlers bound for the following event types will receive a CommandEvent parameter.
See also
__init__ | Default constructor. |
Create | Creates the choice for two-step construction. |
FindString | Finds an item whose label matches the given string. |
GetColumns | Gets the number of columns in this choice item. |
GetCount | Returns the number of items in the control. |
GetCurrentSelection | Unlike ControlWithItems.GetSelection which only returns the accepted selection value, i.e. |
GetSelection | Returns the index of the selected item or NOT_FOUND if no item is selected. |
GetString | Returns the label of the item with the given index. |
IsSorted | |
SetColumns | Sets the number of columns in this choice item. |
SetSelection | Sets the selection to the given item n or removes the selection entirely if n == NOT_FOUND . |
SetString | Sets the label for the given item. |
Columns | See GetColumns and SetColumns |
Count | See GetCount |
CurrentSelection | See GetCurrentSelection |
Selection | See GetSelection and SetSelection |
A choice item is used to select one of a list of strings.
Possible constructors:
Choice()
Choice(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize,
choices=[], style=0, validator=DefaultValidator,
name=ChoiceNameStr)
Overloaded Implementations:
__init__ (self)
Default constructor.
__init__ (self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, choices=[], style=0, validator=DefaultValidator, name=ChoiceNameStr)
Constructor, creating and showing a choice.
Parameters: |
|
---|
Finds an item whose label matches the given string.
Parameters: |
|
---|---|
Return type: | int |
Returns: | The zero-based position of the item, or NOT_FOUND if the string was not found. |
Gets the number of columns in this choice item.
Return type: | int |
---|
Note
This is implemented for GTK and Motif only and always returns 1 for the other platforms.
Returns the number of items in the control.
Return type: | int |
---|
See also
IsEmpty
Unlike ControlWithItems.GetSelection which only returns the accepted selection value, i.e.
the selection in the control once the user closes the dropdown list, this function returns the current selection. That is, while the dropdown list is shown, it returns the currently selected item in it. When it is not shown, its result is the same as for the other function.
Return type: | int |
---|
New in version 2.6.2.: In older versions, ControlWithItems.GetSelection itself behaved like this.
Returns the index of the selected item or NOT_FOUND if no item is selected.
Return type: | int |
---|---|
Returns: | The position of the current selection. |
Note
This method can be used with single selection list boxes only, you should use ListBox.GetSelections for the list boxes with LB_MULTIPLE style.
See also
SetSelection , GetStringSelection
Returns the label of the item with the given index.
Parameters: | n (int) – The zero-based index. |
---|---|
Return type: | string |
Returns: | The label of the item or an empty string if the position was invalid. |
Return type: | bool |
---|
Sets the number of columns in this choice item.
Parameters: | n (int) – Number of columns. |
---|
Note
This is implemented for GTK and Motif only and doesn’t do anything under other platforms.
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. |
---|
See also
SetString , SetStringSelection
Sets the label for the given item.
Parameters: |
|
---|
See GetColumns and SetColumns
See GetSelection and SetSelection