madgui.util.menu module

Utilities for defining a window menu in a more concice notation than manually creating the QMenuItem and assigning properties.

Classes

Item(label, shortcut, description, callback)

Represents a menu item.

Menu(label, items)

(Sub-)menu to be inserted.

Separator()

Separator to be inserted in a menu.

Functions

extend(parent, menu, items)

Append menu items to menu.

class madgui.util.menu.Item(label, shortcut, description, callback, icon=None, enabled=True, checked=None)[source]

Bases: object

Represents a menu item. Objects of this type will be realized as QMenuItem.

The following properties can be given:

Variables
  • label (str) – menu item label

  • shortcut (str) – shortcut, e.g. “Ctrl+S” (optional)

  • description (str) – tooltip and status bar message

  • callback (callable) – action to be taken when clicking the menu item

  • icon – icon, can be QStyle.StandardPixmap, an icon name defined in the theme, or a QIcon

  • enabled (Bool) – whether the item is enabled (optional)

  • checked (Bool) – whether the item is checked (optional)

Methods

action(parent)

Create a QAction from this item.

append_to(menu[, parent])

Append this item to the given menu.

action(parent)[source]

Create a QAction from this item.

append_to(menu, parent=None)[source]

Append this item to the given menu.

class madgui.util.menu.Menu(label, items)[source]

Bases: object

(Sub-)menu to be inserted.

Methods

append_to(menu, parent)

append_to(menu, parent)[source]
class madgui.util.menu.Separator[source]

Bases: object

Separator to be inserted in a menu.

Methods

append_to(menu, parent)

classmethod append_to(menu, parent)[source]
madgui.util.menu.extend(parent, menu, items)[source]

Append menu items to menu.