gale.ui.window module

This file contains the implementation of the class Window: a Panel-backed Container with an optional title and an optional close (“X”) button docked in its top-right corner.

Author: Alejandro Mujica (aledrums@gmail.com)

class gale.ui.window.Window(x, y, width, height, title='', closable=True, on_close=None, close_button_size=20, children=None, theme=None, visible=True)[source]

Bases: Container

A Panel-backed Container with an optional title and an optional close (“X”) button docked in its top-right corner, the way a desktop window or an in-game modal dialog (an inventory, a pause menu, a dialogue box the player can dismiss early) is closed.

Usage example:

def on_close():

print(“closed”)

window = Window(

160, 90, 320, 220, title=”Inventory”, on_close=on_close, children=[ListView(…)],

)

Parameters:
  • x (float)

  • y (float)

  • width (float)

  • height (float)

  • title (str)

  • closable (bool)

  • on_close (Callable[[], None] | None)

  • close_button_size (int)

  • children (Sequence[Widget] | None)

  • theme (Theme | None)

  • visible (bool)

close()[source]

Hide the window and invoke on_close, if any. Safe to call directly (e.g. bound to a keyboard shortcut or another widget’s on_click) even when closable is False.

Return type:

None