Components
Build in Components
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.draw_bounding_box: bool = False
- Properties.layout: str = 'stack'
- 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.z_index: int = 0
Input
- class guimlcomponents.base.text.Input
This component can be used via the tag
input.- class Properties
-
- Properties.draw_bounding_box: bool = False
- Properties.layout: str = 'stack'
- 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.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.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. Useon_initinstead.- 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.
- 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.