lino.core.menus

Defines the classes MenuItem and Menu

(This module's source code is available here.)

Functions

create_item(spec[, action, help_text])

find_menu_item(bound_action)

Classes

Menu(user_type, name[, label, parent])

Represents a menu.

MenuItem([name, label, doc, enabled, ...])

A menu item.

Toolbar(user_type, name[, label, parent])

A top-level menu.

class lino.core.menus.MenuItem(name=None, label=None, doc=None, enabled=True, action=None, hotkey=None, params=None, help_text=None, instance=None, javascript=None, href=None)

Bases: object

A menu item. Note that this is subclassed by Menu: a menu is also a menu item.

as_rst(ar, level=None)

Render this menu item as an rst string. Currently used only for writing test cases.

lino.core.menus.create_item(spec, action=None, help_text=None, **kw)
class lino.core.menus.Menu(user_type, name, label=None, parent=None, **kw)

Bases: lino.core.menus.MenuItem

Represents a menu. A menu is conceptually a MenuItem which contains other menu items.

avoid_lonely_items = False

If set to True, avoid lonely menu items by lifting them up one level. This is not done for top-level menus

For example the following menu:

Foo           Bar         Baz
|Foobar       |BarBaz
 |Copy
 |Paste
|FooBarBaz
 | Insert

would become:

Foo           BarBaz        Baz
|Foobar
 |Copy
 |Paste
|Insert
compress()

Dynamically removes empty menu entries and useless separators. Collapses menu with only one item into their parent.

add_instance_action(obj, **kw)

Add an action which displays the given database object instance in a detail form for editing.

Used e.g. for the :menuselection`Configure --> System --> Site configuration` command. Or for the [My settings] quicklink in Lino Care.

add_item_instance(mi)

Adds the specified MenuItem to this menu after checking whether it has view permission.

class lino.core.menus.Toolbar(user_type, name, label=None, parent=None, **kw)

Bases: lino.core.menus.Menu

A top-level menu.