Plexora

NavItem

One entry a plugin contributes to a core menu.

Generated from Plexora 0.0.55View source
from plexora.api import NavItem

Also available as plexora.api.plugin.NavItem.

NavItem(
    menu: str,
    label: str,
    path: str = '',
    order: int = 0,
    icon: str = '',
    shortcut: str = '',
)

Data, not markup: core renders each entry as a plain link with its own classes, so a plugin cannot style, script or restructure a core menu by contributing to it. Passed as one of Plugin.nav_items.

Fields

menustrrequired

Which core menu this entry appears in: one of NAV_MENUS ("file", "open_project", "help").

labelstrrequired

Text shown for this entry.

pathstrdefault ''

Appended to this plugin's own url_prefix. A plugin can only ever link into its own namespace, which is what stops a nav entry becoming a way to point a core menu at an arbitrary URL.

orderintdefault 0

Sort key within the menu. Ties break on label, so the order is stable whatever sequence plugins were discovered in.

iconstrdefault ''

A Font Awesome name without the fa- prefix, e.g. "images". Core renders it into the menu's icon gutter; a plugin still cannot supply markup, only name a glyph, so this stays as much data as label is.

shortcutstrdefault ''

Keystroke that follows this link, written as in normalize_shortcut. Optional -- an entry with no shortcut simply prints none, and the gutter stays aligned either way.

Examples

from plexora.api.plugin import NavItem

nav_items = (
    NavItem(menu="file", label="Open My Plugin…", path="/library"),
)