Widget Selection

Selection Effect

class pygame_menu.widgets.core.Selection(margin_left, margin_right, margin_top, margin_bottom)[source]

Widget selection class.

Parameters
  • margin_left (int, float) – Left margin

  • margin_right (int, float) – Right margin

  • margin_top (int, float) – Top margin

  • margin_bottom (int, float) – Bottom margin

draw(surface, widget)[source]

Draw the selection.

Parameters
  • surface (pygame.Surface) – Surface to draw

  • widget (pygame_menu.widgets.core.Widget) – Widget object

Returns

None

get_height()[source]

Return the selection height (px) as sum of top and bottom margins.

Returns

Height in px

Return type

int, float

get_margin()[source]

Return the top, left, bottom and right margins of the selection.

Returns

Tuple of (top,left,bottom,right) margins in px

Return type

tuple

get_width()[source]

Return the selection width (px) as sum of left and right margins.

Returns

Width in px

Return type

int, float

get_xy_margin()[source]

Returns the x/y margins of the selection.

Returns

Tuple of (x,y) margins

Return type

tuple

inflate(rect)[source]

Grow or shrink the rectangle size according to margins.

Parameters

rect (pygame.Rect) – Rect object

Returns

Inflated rect

Return type

pygame.Rect

set_color(color)[source]

Set the selection color.

Parameters

color (tuple, list) – Selection color

Returns

None

Highlight Selection Effect

class pygame_menu.widgets.HighlightSelection(border_width=1, margin_x=16, margin_y=8)[source]

Bases: pygame_menu.widgets.core.selection.Selection

Widget selection highlight class.

Note

Widget background color may not reach the entire selection area

Parameters
  • border_width (int) – Border width of the highlight box

  • margin_x (int, float) – X margin of selected highlight box

  • margin_y (int, float) – X margin of selected highlight box

draw(surface, widget)[source]

Draw the selection.

Parameters
  • surface (pygame.Surface) – Surface to draw

  • widget (pygame_menu.widgets.core.Widget) – Widget object

Returns

None

Left Arrow Selection Effect

class pygame_menu.widgets.LeftArrowSelection(arrow_size=(10, 15), arrow_right_margin=5, arrow_vertical_offset=0, blink_ms=0)[source]

Bases: pygame_menu.widgets.selection.arrow_selection.ArrowSelection

Widget selection left arrow class. Creates an arrow to the left of the selected menu item.

Parameters
  • arrow_size (tuple, list) – Size of arrow on (x,y) axis (width,height)

  • arrow_right_margin (int, float) – Distance from the arrow to the widget

  • arrow_vertical_offset (int) – Vertical offset of the arrow

  • blink_ms (int, float) – Milliseconds between each blink, if 0 blinking is disabled

draw(surface, widget)[source]

Draw the selection.

Parameters
  • surface (pygame.Surface) – Surface to draw

  • widget (pygame_menu.widgets.core.Widget) – Widget object

Returns

None

None Selection Effect

class pygame_menu.widgets.NoneSelection[source]

Bases: pygame_menu.widgets.core.selection.Selection

No selection effect.

draw(surface, widget)[source]

Draw the selection.

Parameters
  • surface (pygame.Surface) – Surface to draw

  • widget (pygame_menu.widgets.core.Widget) – Widget object

Returns

None

Right Arrow Selection Effect

class pygame_menu.widgets.RightArrowSelection(arrow_size=(10, 15), arrow_left_margin=3, arrow_vertical_offset=0, blink_ms=0)[source]

Bases: pygame_menu.widgets.selection.arrow_selection.ArrowSelection

Widget selection right arrow class. Creates an arrow to the right of the selected menu item.

Parameters
  • arrow_size (tuple, list) – Size of arrow on (x,y) axis (width,height)

  • arrow_left_margin (int, float) – Distance from the arrow to the widget

  • arrow_vertical_offset (int) – Vertical offset of the arrow

  • blink_ms (int, float) – Milliseconds between each blink, if 0 blinking is disabled

draw(surface, widget)[source]

Draw the selection.

Parameters
  • surface (pygame.Surface) – Surface to draw

  • widget (pygame_menu.widgets.core.Widget) – Widget object

Returns

None