pygvisuals.borders package

Package for borders compatible with pygame’s surfaces; intended to be used together with PyGVisuals’ widgets.

class pygvisuals.borders.BevelBorder(width, height, upper, lower, lower_has_left_side=False)[source]

Bases: pygvisuals.borders.border.Border

Border with two colored lines, creating a simple bevel-effect.

Initialisation of a BevelBorder.

Parameters
  • width – The width of the border. This can either be an integer for the width of both the left and right side or a tuple for each side specifically (left, right).

  • height – The height of the border. This can either be an integer for the height of both the top and bottom side or a tuple for each side specifically (top, bottom).

  • upper – A color-like object that can be interpreted as a color by pygame (such as a tuple with RGB values). This will be used as the color for the upper side of the border.

  • lower – A color-like object that can be interpreted as a color by pygame (such as a tuple with RGB values). This will be used as the color for the lower side of the border.

  • lower_has_left_side – A boolean indicating whether the left side will be filled in with the same color as the lower/bottom side. The default is False, which means that the left side will have the same color as the top side.

class pygvisuals.borders.Border(width, height)[source]

Bases: object

Underlying class for borders compatible with pygame’s surfaces. Intended to be used together with PyGVisuals’ widgets. A border will have four sides, surrounding a provided surface.

Initialisation of a Border.

Parameters
  • width – The width of the border. This can either be an integer for the width of both the left and right side or a tuple for each side specifically (left, right).

  • height – The height of the border. This can either be an integer for the height of both the top and bottom side or a tuple for each side specifically (top, bottom).

getBorderedImage(surface, *args)[source]

Draw the border surrounding the given surface if needed and return the result.

Parameters
  • surface – A surface-like object (e.g. pygame.Surface) that should be bordered.

  • *args – Any arguments provided for the update. This can include an optional pygame.event.Event to process.

Returns

A pygame.Surface with the bordered result.

getBounds(rect)[source]

Return the new size of a rect if it was to be bordered with this border.

Parameters

rect – A rect-like object (e.g. pygame.Rect) to calculate the new bounds from.

Returns

A rect-like object (e.g. pygame.Rect) with the size if it was to be bordered with this border.

isEmptyBorder()[source]

Return whether the border is empty and therefore of zero size. An empty border needs not to be drawn.

Returns

A boolean indicating whether all sides of the border have zero width.

class pygvisuals.borders.ColoredBorder(width, height, color)[source]

Bases: pygvisuals.borders.border.Border

Border with a color.

Initialisation of a ColoredBorder.

Parameters
  • width – The width of the border. This can either be an integer for the width of both the left and right side or a tuple for each side specifically (left, right).

  • height – The height of the border. This can either be an integer for the height of both the top and bottom side or a tuple for each side specifically (top, bottom).

  • color – A color-like object that can be interpreted as a color by pygame (such as a tuple with RGB values). This will be used as the color for the border.

class pygvisuals.borders.CompoundBorder(inner, outer)[source]

Bases: pygvisuals.borders.border.Border

Border composed of two other borders.

Initialisation of a CompoundBorder.

Parameters
  • inner – A border which will be used as the inner part of the CompoundBorder.

  • outer – A border which will be used as the outer part of the CompoundBorder.

getBorderedImage(surface, *args)[source]

Draw the border surrounding the given surface if needed and return the result.

Parameters
  • surface – A surface-like object (e.g. pygame.Surface) that should be bordered.

  • *args – Any arguments provided for the update. This can include an optional pygame.event.Event to process.

Returns

A pygame.Surface with the bordered result.

class pygvisuals.borders.RoundedBorder(width, height, color, radius, surface_above_border=False)[source]

Bases: pygvisuals.borders.colored_border.ColoredBorder

Border with rounded corners, which can be colored.

Initialisation of a RoundedBorder. The rounded rectangle is produced by placing 4 circles on the side of the rectangle as described here: https://github.com/pygame/pygame/issues/1120

Parameters
  • width – The width of the border. This can either be an integer for the width of both the left and right side or a tuple for each side specifically (left, right).

  • height – The height of the border. This can either be an integer for the height of both the top and bottom side or a tuple for each side specifically (top, bottom).

  • color – A color-like object that can be interpreted as a color by pygame (such as a tuple with RGB values). This will be used as the color for the border.

  • radius – An integer denoting the radius in pixels of the circles on the corners of the RoundedBorder.

  • surface_above_border – A boolean controling whether the border will be drawn behind the surface or on top of it. The default value is False, meaning the border will be drawn on top of the surface.

Submodules

pygvisuals.borders.bevel_border module

class pygvisuals.borders.bevel_border.BevelBorder(width, height, upper, lower, lower_has_left_side=False)[source]

Bases: pygvisuals.borders.border.Border

Border with two colored lines, creating a simple bevel-effect.

Initialisation of a BevelBorder.

Parameters
  • width – The width of the border. This can either be an integer for the width of both the left and right side or a tuple for each side specifically (left, right).

  • height – The height of the border. This can either be an integer for the height of both the top and bottom side or a tuple for each side specifically (top, bottom).

  • upper – A color-like object that can be interpreted as a color by pygame (such as a tuple with RGB values). This will be used as the color for the upper side of the border.

  • lower – A color-like object that can be interpreted as a color by pygame (such as a tuple with RGB values). This will be used as the color for the lower side of the border.

  • lower_has_left_side – A boolean indicating whether the left side will be filled in with the same color as the lower/bottom side. The default is False, which means that the left side will have the same color as the top side.

pygvisuals.borders.border module

class pygvisuals.borders.border.Border(width, height)[source]

Bases: object

Underlying class for borders compatible with pygame’s surfaces. Intended to be used together with PyGVisuals’ widgets. A border will have four sides, surrounding a provided surface.

Initialisation of a Border.

Parameters
  • width – The width of the border. This can either be an integer for the width of both the left and right side or a tuple for each side specifically (left, right).

  • height – The height of the border. This can either be an integer for the height of both the top and bottom side or a tuple for each side specifically (top, bottom).

getBorderedImage(surface, *args)[source]

Draw the border surrounding the given surface if needed and return the result.

Parameters
  • surface – A surface-like object (e.g. pygame.Surface) that should be bordered.

  • *args – Any arguments provided for the update. This can include an optional pygame.event.Event to process.

Returns

A pygame.Surface with the bordered result.

getBounds(rect)[source]

Return the new size of a rect if it was to be bordered with this border.

Parameters

rect – A rect-like object (e.g. pygame.Rect) to calculate the new bounds from.

Returns

A rect-like object (e.g. pygame.Rect) with the size if it was to be bordered with this border.

isEmptyBorder()[source]

Return whether the border is empty and therefore of zero size. An empty border needs not to be drawn.

Returns

A boolean indicating whether all sides of the border have zero width.

pygvisuals.borders.colored_border module

class pygvisuals.borders.colored_border.ColoredBorder(width, height, color)[source]

Bases: pygvisuals.borders.border.Border

Border with a color.

Initialisation of a ColoredBorder.

Parameters
  • width – The width of the border. This can either be an integer for the width of both the left and right side or a tuple for each side specifically (left, right).

  • height – The height of the border. This can either be an integer for the height of both the top and bottom side or a tuple for each side specifically (top, bottom).

  • color – A color-like object that can be interpreted as a color by pygame (such as a tuple with RGB values). This will be used as the color for the border.

pygvisuals.borders.compound_border module

class pygvisuals.borders.compound_border.CompoundBorder(inner, outer)[source]

Bases: pygvisuals.borders.border.Border

Border composed of two other borders.

Initialisation of a CompoundBorder.

Parameters
  • inner – A border which will be used as the inner part of the CompoundBorder.

  • outer – A border which will be used as the outer part of the CompoundBorder.

getBorderedImage(surface, *args)[source]

Draw the border surrounding the given surface if needed and return the result.

Parameters
  • surface – A surface-like object (e.g. pygame.Surface) that should be bordered.

  • *args – Any arguments provided for the update. This can include an optional pygame.event.Event to process.

Returns

A pygame.Surface with the bordered result.

pygvisuals.borders.rounded_border module

class pygvisuals.borders.rounded_border.RoundedBorder(width, height, color, radius, surface_above_border=False)[source]

Bases: pygvisuals.borders.colored_border.ColoredBorder

Border with rounded corners, which can be colored.

Initialisation of a RoundedBorder. The rounded rectangle is produced by placing 4 circles on the side of the rectangle as described here: https://github.com/pygame/pygame/issues/1120

Parameters
  • width – The width of the border. This can either be an integer for the width of both the left and right side or a tuple for each side specifically (left, right).

  • height – The height of the border. This can either be an integer for the height of both the top and bottom side or a tuple for each side specifically (top, bottom).

  • color – A color-like object that can be interpreted as a color by pygame (such as a tuple with RGB values). This will be used as the color for the border.

  • radius – An integer denoting the radius in pixels of the circles on the corners of the RoundedBorder.

  • surface_above_border – A boolean controling whether the border will be drawn behind the surface or on top of it. The default value is False, meaning the border will be drawn on top of the surface.