Skip to content

UI Element

Element

Element(scene: 'Scene', parent: Element)

Bases: ABC

Base User-Interface Element/Object.

Create a new inherited UI element.

enabled instance-attribute

enabled: bool = True

If this element is enabled.

bounds abstractmethod property

bounds: pygame.Rect

The bounding pygame.Rect of this element.

children property

children: tuple[Element]

All children of this element.

parent property

parent: Element

The parent of this element.

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 abstractmethod

render() -> None

Forceably render this element to the screen using an already-implemented Pygame rendering program.

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.

tween abstractmethod

tween(
    end, duration: float, easing: Callable[[float], float]
) -> None

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