GUI menu system
Menu
Menu is a high-level inventory GUI system with click handlers. It wraps Inventory with per-slot click callbacks using MenuItem.
Constructor
Menu(title="", rows=3)
Create a menu.
- Parameters:
title(str) — Title displayed at the top. Supports§color codes.rows(int) — Number of rows (1–6). Each row has 9 slots. Default 3.
shop = Menu("§6§lItem Shop", rows=3)
Attributes
title
- Type:
str
Menu title.
rows
- Type:
int
Number of rows.
Slot Access
Menu supports index-based access using [] notation.
Set a slot
menu[slot] = menu_item
- Parameters:
slot(int) — Slot index (0-based, left-to-right, top-to-bottom).menu_item(MenuItem) — Item with click handler.
Get a slot
item = menu[slot]
- Returns:
MenuItem| None
Delete a slot
del menu[slot]
Methods
fill_border
menu.fill_border(item)
Fill the border slots with a decorative item. This is synchronous.
- Parameters:
item(Item) — Item to use for the border.
shop = Menu("§6§lShop", rows=3)
shop.fill_border(Item("GRAY_STAINED_GLASS_PANE", name=" "))
open
menu.open(player)
Open this menu for a player. This is synchronous.
- Parameters:
player(Player) — Player to show the menu to.
Tip: See MenuItem for click handler details and examples.