Skip to content

UI Frame

Frame

Frame(
    scene: "Scene",
    parent: Element,
    *,
    position: tuple[Union[int, float], Union[int, float]],
    size: tuple[Union[int, float], Union[int, float]],
    anchor: Anchor = Anchor.TOP_LEFT,
    color: ColorRGBA = None
)

Bases: Element

User-Interface Frame.

Create a new user interface frame.

PARAMETER DESCRIPTION
scene

The scene to interface this instance with.

TYPE: Scene

parent

Any ~Element-like object to make the parent of this instance.

TYPE: Element

position
  • The X and Y values for the pixels in which this element will be placed.
  • If int they represent absolute pixel values, otherwise (float) will represent scaled pixel values.

TYPE: tuple[int | float, int | float]

size
  • The X and Y values for the pixels in which this element will be sized.
  • If int they represent absolute pixel values, otherwise (float) will represent scaled pixel values.

TYPE: tuple[int | float, int | float]

anchor

The chosen area of this element to place at the position provided.

TYPE: Anchor DEFAULT: Anchor.TOP_LEFT

color

If provided, the color of this element when rendered.

TYPE: ColorRGBA DEFAULT: None

RAISES DESCRIPTION
TypeError
  • Provided anchor isn't an Anchor object.
  • Provided position X and Y values aren't int or float.
  • Provided size X and Y values aren't int or `float.
ValueError
  • If any value of position or size are float and are not between 0 and 1.
  • If values of position and size are not two values in length.

color property writable

color: Union[ColorRGBA, None]

The color of this frame - Can be None.

enabled instance-attribute

enabled: bool = True

If this element is enabled.

children property

children: tuple[Element]

All children of this element.

parent property

parent: Element

The parent of this element.

set_border

set_border(
    color: ColorRGBA = None,
    *,
    width: int = 1,
    radius: int = 0,
    radius_bottom_left: int = None,
    radius_bottom_right: int = None,
    radius_top_left: int = None,
    radius_top_right: int = None
) -> None

Set the border attributes of this element.

PARAMETER DESCRIPTION
color

The color to set the border as - None will disable the border.

TYPE: ColorRGBA DEFAULT: None

width

The width of the border - None/0 will disable the border.

TYPE: int DEFAULT: 1

radius

The radius of the border - Initial value of all corners unless overriden by following parameters.

TYPE: int DEFAULT: 0

radius_bottom_left

The radius of the bottom left corner.

TYPE: int DEFAULT: None

radius_bottom_right

The radius of the bottom right corner.

TYPE: int DEFAULT: None

radius_top_left

The radius of the top left corner.

TYPE: int DEFAULT: None

radius_top_right

The radius of the top right corner.

TYPE: int DEFAULT: None

RAISES DESCRIPTION
TypeError
  • If width is not an int.
  • If any radius value isn't an int.
ValueError

If any radius value is less than 0.

set_transform

set_transform(
    *,
    anchor: Anchor = None,
    position: tuple[
        Union[int, float], Union[int, float]
    ] = None,
    size: tuple[Union[int, float], Union[int, float]] = None
) -> None

Set the transform (position, size, anchor) attributes of this element.

PARAMETER DESCRIPTION
anchor

If provided, change the anchor point of this element.

TYPE: Anchor DEFAULT: None

position

If provided, change the position of this element - int for absolute, float for scaled.

TYPE: tuple[int | float, int | float] DEFAULT: None

size

If provided, change the size of this element - int for absolute, float for scaled.

TYPE: tuple[int | float, int | float] DEFAULT: None

Info

anchor, position, or size are optional, but one has to be specified.

RAISES DESCRIPTION
TypeError
  • Provided anchor isn't an Anchor object.
  • Provided position X and Y values aren't int or float.
  • Provided size X and Y values aren't int or `float.
ValueError
  • If none of the parameters above are provided.
  • If any value of position or size are float and are not between 0 and 1.

tween

tween(
    *,
    position: Iterable[Union[int, float]] = None,
    size: Iterable[Union[int, float]] = None,
    duration: float,
    easing: Callable[[float], float] = Easing.LINEAR
) -> None

Tween/animate this element to an end state over a period of time.

PARAMETER DESCRIPTION
position

The end position to reach, if provided.

TYPE: typing.Iterable[int | float] DEFAULT: None

size

The end size to reach, if provided.

TYPE: typing.Iterable[int | float] DEFAULT: None

duration

The time in which it'll take to animate this element in seconds.

TYPE: float

easing

The easing function to use when animating.

TYPE: typing.Callable[[float], float] DEFAULT: Easing.LINEAR

Info
  • Parameters position and size are mutually exclusive.
  • Either one, or both, has to be passed.
RAISES DESCRIPTION
TypeError
  • If position or size are not iterable objects.
  • If duration is not int or float.
ValueError
  • If position and size are not defined.
  • If position or size don't contain only two values.
  • If position, size, or duration don't contain int or float values.

add_child

add_child(child: Element) -> None

Add a child to this element.

PARAMETER DESCRIPTION
child

The child to add to this element.

TYPE: Element

RAISES DESCRIPTION
TypeError

If the child provided is not an Element.

remove_child

remove_child(child: Element) -> None

Remove a child from this element.

PARAMETER DESCRIPTION
child

The child to remove from this element.

TYPE: Element

RAISES DESCRIPTION
TypeError

If the child provided is not an Element.

render_opengl

render_opengl() -> None

Forceably render this element to the screen using a custom-implemented OpenGL rendering program.

request_render

request_render() -> None

Render this element and it's children to the screen, if enabled.

set_tween_callback

set_tween_callback(
    callback: Callable[[None], None],
) -> None

Set a callback method for when this element finishes tweening/animating.