Button

class pygame_menu.widgets.Button(label, button_id='', onchange=None, onreturn=None, *args, **kwargs)[source]

Bases: pygame_menu.widgets.core.widget.Widget

Button widget.

Parameters:
  • label (str) – Text of the button
  • button_id (str) – Button ID
  • onchange (callable, None) – Callback when changing the selector
  • onreturn (callable, None) – Callback when pressing return button
  • args (any) – Optional arguments for callbacks
  • kwargs (any) – Optional keyword-arguments for callbacks
draw(surface)[source]

Draw the widget shape.

Parameters:surface (pygame.Surface) – Surface to draw
Returns:None
update(events)[source]

Update internal variable according to the given events list and fire the callbacks.

Parameters:events (list[pygame.event.Event]) – List of pygame events
Returns:True if updated
Return type:bool