tuxemon.menu.interface module

class tuxemon.menu.interface.Bar(value=1.0)[source]

Bases: object

Common bar class for UI elements.

Parameters:

value (float) –

bg_color: ClassVar[Color | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None] = (0, 0, 0)
border: ClassVar[GraphicBox] = None
border_filename: ClassVar[str]
static calc_inner_rect(rect)[source]

Calculate inner rectangle.

Calculate the inner rect to draw fg_color that fills bar The values here are calculated based on game scale and the content of the border image file.

Parameters:

rect (Rect) – Outside rectangle.

Returns:

Inner rectangle.

Return type:

Rect

draw(surface, rect)[source]

Draws the bar.

Parameters:
  • surface (Surface) – Surface where to draw the bar.

  • rect (Rect) – Location and size of the bar.

Return type:

None

fg_color: ClassVar[Color | str | Tuple[int, int, int] | Tuple[int, int, int, int]] = (255, 255, 255)
load_graphics()[source]

Load the border image.

Image become class attribute, so is shared. Eventually, implement some game-wide image caching.

Return type:

None

class tuxemon.menu.interface.ExpBar(value=1.0)[source]

Bases: Bar

EXP bar for UI elements.

Parameters:

value (float) –

bg_color: ClassVar[Color | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None] = None
border: ClassVar[GraphicBox] = None
border_filename: ClassVar[str] = 'gfx/ui/monster/exp_bar.png'
fg_color: ClassVar[Color | str | Tuple[int, int, int] | Tuple[int, int, int, int]] = (31, 239, 255)
class tuxemon.menu.interface.HpBar(value=1.0)[source]

Bases: Bar

HP bar for UI elements.

Parameters:

value (float) –

bg_color: ClassVar[Color | str | Tuple[int, int, int] | Tuple[int, int, int, int] | None] = (245, 10, 25)
border: ClassVar[GraphicBox] = None
border_filename: ClassVar[str] = 'gfx/ui/monster/hp_bar.png'
fg_color: ClassVar[Color | str | Tuple[int, int, int] | Tuple[int, int, int, int]] = (10, 240, 25)
class tuxemon.menu.interface.MenuCursor(image)[source]

Bases: Sprite

Menu cursor.

Typically it is an arrow that shows the currently selected menu item.

Parameters:

image (pygame.surface.Surface) – Image that represents the cursor.

class tuxemon.menu.interface.MenuItem(image, label, description, game_object)[source]

Bases: Generic[T], Sprite

Item from a menu.

Parameters:
  • image – Image of the menu item.

  • label – Name of the menu item.

  • description – Description of the menu item.

  • game_object – Callable used when the menu item is selected.

property in_focus: bool
toggle_focus()[source]

Toggles the focus of the menu item.

Return type:

None