BoxElement

class pygamepopup.components.BoxElement(*args, **kwargs)

This element acts as a wrapper for a gui element. In fact, it adds a margin to any border of an element to have a cleaner interface.

Keyword Arguments:
  • position (Position) – the position of the box on the screen.

  • content (Optional[pygame.Surface]) – a surface that will be wrapped by the box.

  • margin (Margin) – a tuple containing the margins of the box, should be in the form “(top_margin, right_margin, bottom_margin, left_margin), defaults to (0, 0, 0, 0)”.

  • column_span (int) – the number of columns the element should span, defaults to 1.

position

the position of the box on the screen.

Type:

Position

content

the element wrapped in the box.

Type:

Optional[pygame.Surface]

size

the size of the content following the format “(width, height)”

Type:

tuple[int, int]

margin

a dict containing all the values for margins TOP, BOTTOM, LEFT and RIGHT.

Type:

dict[str, int]

column_span

the number of columns the element should span.

Type:

int

display(screen)

Display the content of the box, following the margins that should be added around it.

Keyword Arguments:

screen (pygame.Surface) – the screen on which the content of the box should be drawn

get_height()
Returns:

the height of the content more the top and bottom margins

Return type:

int

get_margin_bottom()
Returns:

bottom margin

Return type:

int

get_margin_left()
Returns:

left margin

Return type:

int

get_margin_right()
Returns:

right margin

Return type:

int

get_margin_top()
Returns:

top margin

Return type:

int

get_rect()
Returns:

a pygame rect containing the position of the element and its size

Return type:

pygame.Rect

get_width()
Returns:

the width of the content more the left and right margins

Return type:

int