gale.ui.container module

This file contains the implementation of the class Container: a scene-graph node holding any number of child widgets, dispatching input to them (mouse hit-testing, keyboard focus/navigation) and rendering/updating them in add order.

Author: Alejandro Mujica (aledrums@gmail.com)

class gale.ui.container.Container(x, y, width, height, children=None, theme=None, visible=True)[source]

Bases: Widget

A real scene-graph node holding any number of child widgets. Rendered/updated in add order (which is also z-order: to bring a widget to front, remove and re-add it). Mouse events hit-test children in reverse add order (top-most first) and stop at the first one that consumes the event. on_confirm/on_navigate are forwarded only to the currently focused child; an unconsumed on_navigate instead moves focus to the next focusable sibling.

Usage example:

menu = Container(40, 40, 240, 160, children=[

Panel(40, 40, 240, 160), ListView(48, 48, 224, 144, items=[(“Host”, start_hosting), (“Join”, start_joining)]),

])

Parameters:
  • x (float)

  • y (float)

  • width (float)

  • height (float)

  • children (Sequence[Widget] | None)

  • theme (Theme | None)

  • visible (bool)

property focusable: bool

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

add_child(widget)[source]
Parameters:

widget (Widget)

Return type:

None

remove_child(widget)[source]
Parameters:

widget (Widget)

Return type:

None

update(dt)[source]
Parameters:

dt (float)

Return type:

None

render(surface)[source]
Parameters:

surface (Surface)

Return type:

None

on_mouse_motion(position)[source]
Parameters:

position (Tuple[float, float])

Return type:

None

on_mouse_click(position, data)[source]
Parameters:
Return type:

bool

on_confirm()[source]
Return type:

bool

on_navigate(direction)[source]
Parameters:

direction (Tuple[int, int])

Return type:

bool