gale.ui.widget module
This file contains the implementation of the class Widget, the base every gale.ui widget (Panel, Button, Container, …) derives from.
Author: Alejandro Mujica (aledrums@gmail.com)
- class gale.ui.widget.Widget(x, y, width, height, theme=None, visible=True, enabled=True)[source]
Bases:
objectBase class for anything gale.ui can render and route input to.
A subclass overrides update/render to draw itself, and whichever of on_mouse_motion/on_mouse_click/on_confirm/on_navigate it reacts to. on_mouse_click, on_confirm, and on_navigate return a bool meaning “did I consume this?”, so a Container knows whether to keep forwarding the same input to something else (a click behind a focused widget should not also reach whatever is under it).
- Parameters:
x (float)
y (float)
width (float)
height (float)
theme (Theme | None)
visible (bool)
enabled (bool)
- focusable: bool = False
- x: float
- y: float
- width: float
- height: float
- visible: bool
- enabled: bool
- focused: bool
- hovered: bool
- wants_raw_keyboard: bool
- property rect: Rect
- contains(position)[source]
- Parameters:
position (Tuple[float, float]) – A point, in the same coordinate space as x/y.
- Returns:
Whether position is inside this widget’s rect.
- Return type:
bool
- on_mouse_click(position, data)[source]
- Parameters:
position (Tuple[float, float])
data (MouseClickData)
- Return type:
bool
- Parameters:
direction (Tuple[int, int])
- Return type:
bool