gale.ui.list_view module
This file contains the implementation of the class ListView: a vertical list of selectable (label, on_select) items, navigable by mouse or keyboard/gamepad.
Author: Alejandro Mujica (aledrums@gmail.com)
- class gale.ui.list_view.ListView(x, y, width, height, items, font=None, cursor=None, theme=None)[source]
Bases:
WidgetA vertical list of selectable items, each a (label, on_select) pair. Supports both keyboard navigation (on_navigate moves the selection with wraparound, on_confirm invokes the selected item) and mouse interaction (hovering highlights, clicking selects and invokes). This is the generalization of gale.ui’s “menu”: build a menu as Container([Panel(…), ListView(…)]).
Usage example:
- menu = ListView(
40, 40, 240, 120, items=[(“Host”, start_hosting), (“Join”, start_joining), (“Quit”, quit_game)],
)
- Parameters:
- on_mouse_click(position, data)[source]
- Parameters:
position (Tuple[float, float])
data (MouseClickData)
- Return type:
bool
- Parameters:
direction (Tuple[int, int])
- Return type:
bool