ion.ui

This module shows the transient UI the compositor draws itself: context menus, messages and tooltips. Only one popup is shown at a time, and popup_dismiss() takes down whichever is current.

Menus

popup_menu() takes the entries directly, which suits a menu whose contents depend on what was clicked. A menu that is reused, or that wants a name to bind a key to, belongs in MenuRegistry instead.

Either way every operator is polled before the menu appears, so an entry whose operator refuses is drawn greyed rather than looking live and doing nothing when clicked. Build the entries unconditionally and let the poll decide what is available.

import ion

ion.ui.popup_menu([
    ("Close", ion.ops.window_close()),
    ("Fullscreen", ion.ops.window_fullscreen_set()),
])

UI elements: popup menus, messages, and tooltips.

Functions

ion.ui.popup_dismiss()

Dismiss the popup currently shown, if any.

Return type:

None

ion.ui.popup_menu(items)

Show a context menu built from (label, operator) tuples.

Every operator is polled before the menu is shown, as it is for the named menus show() displays, so an item whose operator refuses is drawn greyed rather than looking live and doing nothing when clicked.

Parameters:

items (list[tuple[str, NamedTuple]]) – The entries to show, as (label, operator) tuples.

Return type:

None

ion.ui.popup_message(text)

Show a transient message popup.

Parameters:

text (str) – The message to show.

Return type:

None

ion.ui.popup_tooltip(text)

Show a tooltip.

Parameters:

text (str) – The tooltip text.

Return type:

None