Components

Build in Components

Button

Div

class guiml.components.Div

A simple container with a border, margin, padding and a background color.

This component can be used via the tag div.

class Properties
Properties.background: Color
Properties.border: Border
Properties.draw_bounding_box: bool = False
Properties.layout: str = 'stack'
Properties.margin: Rectangle
Properties.mouse_cursor: Literal['', 'default', 'crosshair', 'hand', 'help', 'no', 'size', 'size_down', 'size_down_left', 'size_down_right', 'size_left', 'size_left_right', 'size_right', 'size_up', 'size_up_down', 'size_up_left', 'size_up_right', 'text', 'wait', 'wait_arrow'] = ''

See the pyglet documentation for the possible values.

Properties.on_click: Callable | None = None
Properties.padding: Rectangle
Properties.position: Rectangle

The Bounding box for the component to draw in.

Properties.z_index: int = 0

Input

class guimlcomponents.base.text.Input

This component can be used via the tag input.

class Properties
Properties.background: Color
Properties.border: Border
Properties.draw_bounding_box: bool = False
Properties.layout: str = 'stack'
Properties.margin: Rectangle
Properties.mouse_cursor: Literal['', 'default', 'crosshair', 'hand', 'help', 'no', 'size', 'size_down', 'size_down_left', 'size_down_right', 'size_left', 'size_left_right', 'size_right', 'size_up', 'size_up_down', 'size_up_left', 'size_up_right', 'text', 'wait', 'wait_arrow'] = ''

See the pyglet documentation for the possible values.

Properties.on_click: Callable | None = None
Properties.on_submit: Callable | None = None
Properties.padding: Rectangle
Properties.position: Rectangle

The Bounding box for the component to draw in.

Properties.text: str = None
Properties.z_index: int = 0

Svg

Text

class guimlcomponents.base.text.Text

This component can be used via the tag text.

class Properties
Properties.apply_markup: bool = True

Whether to apply pango markup or to escape it.

Properties.draw_bounding_box: bool = False
Properties.mouse_cursor: Literal['', 'default', 'crosshair', 'hand', 'help', 'no', 'size', 'size_down', 'size_down_left', 'size_down_right', 'size_left', 'size_left_right', 'size_right', 'size_up', 'size_up_down', 'size_up_left', 'size_up_right', 'text', 'wait', 'wait_arrow'] = ''

See the pyglet documentation for the possible values.

Properties.on_click: Callable | None = None
Properties.position: Rectangle

The Bounding box for the component to draw in.

Properties.selectable: bool = True

Whether the text can be selected. You can also use the class no_select to set this value, while also adjusting the style accordingly.

Properties.text: str = ''

The text to display.

Properties.z_index: int = 0

Window

class guimlcomponents.base.window.Window

This component can be used via the tag window.

class Properties
Properties.background: Color | None = Color(red=1, green=1, blue=1, alpha=1)

Background color to draw or None to draw nothing

Properties.height: int = 400
Properties.layout: str = 'stack'
Properties.left: int = 2000
property Properties.position
Properties.resizable: bool = False
Properties.show_fps: bool = False
Properties.top: int = 500
Properties.width: int = 400

Important base classes for components

Component

class guiml.components.Component

Note

The constructor of a component will be called automatically. Therefore, you may not change the arguments when inheriting from this class and you are generally discuraged from providing your own __init__ methode. Use on_init instead.

class Dependencies

The dependencies dataclass is used to specify all dependencies of a component. Dependencies will be automatically injected when the component is constructed. The Properties instance can be acccessed through self.dependencies.

Note

When inheriting a component, make sure to also inherit the Dependencies dataclass.

class Properties

The properties dataclass is used to specify all properties of a component. Properties will be automatically injected when the component is constructed and will be replaced with every draw cycle. The Properties instance can be acccessed through self.properties.

Note

When inheriting a component, make sure to also inherit the Properties dataclass.

on_destroy()

This method is called when the component will be removed from the application.

on_init()

This method is called when the component is initialized.

DrawableComponent

class guiml.components.DrawableComponent

A base class for all components that draw onto the window.

class Properties
Properties.draw_bounding_box: bool = False
Properties.position: Rectangle

The Bounding box for the component to draw in.

Properties.z_index: int = 0
on_draw(context)

By inheriting from this component and overwriting this method you can add additional draw commands to the cairo context.

Remember to call super().on_draw(context) if you want to inherit drawing behaviour.

Args:

context: The cairo context to draw on.

Container

class guiml.components.Container

Base class for containers that are compatible with the builtin layouts.

class Properties
Properties.layout: str = 'stack'
property height
property width
property wrap_size

The wrap size is the additional size for each direction that this component needs around its content.

Property Types

class guimlcomponents.base.shared.Color
alpha: float = 0.0
blue: float = 0.0
green: float = 0.0
red: float = 0.0
class guimlcomponents.base.shared.Border
color: Color
width: int = 0
class guimlcomponents.base.shared.Rectangle
top: int = 0
left: int = 0
bottom: int = 0
right: int = 0