Selector¶
Bases:
pygame_menu.widgets.core.widget.Widget
Selector widget.
Parameters: - label (str) – Selector label text
- elements (list) – Elements of the selector
- selector_id (str) – ID of the selector
- default (int) – Index of default element to display
- onchange (callable, None) – Callback when changing the selector
- onreturn (callable, None) – Callback when pressing return button
- kwargs (any) – Optional keyword-arguments for callbacks
Draw the widget shape.
Parameters: surface ( pygame.Surface
) – Surface to drawReturns: None
Return the current value of the selector at the selected index.
Returns: Value and index as a tuple, (value, index) Return type: tuple
Move selector to left.
Returns: None
Move selector to right.
Returns: None
Set the current value of the widget, selecting the element that matches the text if item is a string, or the index of the position of item is an integer.
- For example, if selector is [[‘a’,0],[‘b’,1],[‘a’,2]]:
- widget.set_value(‘a’) -> Widget selects 0 (first match)
- widget.set_value(2) -> Widget selects 2.
Parameters: item (str, int) – Item to select, can be a string or an integer. Returns: None
Update internal variable according to the given events list and fire the callbacks.
Parameters: events (list[ pygame.event.Event
]) – List of pygame eventsReturns: True if updated Return type: bool
Update selector elements.
Parameters: elements (Object) – Elements of the selector Returns: None