52. gui.menu — Menus for the pyFormex GUI.

This modules implements specialized classes and functions for building the pyFormex GUI menu system.

52.1. Classes defined in module gui.menu

class gui.menu.BaseMenu(title='AMenu', parent=None, before=None, items=None)[source]

A general menu class.

A hierarchical menu that keeps a list of its item names and actions. The item names are normalized by removing all ‘&’ characters and converting the result to lower case. It thus becomes easy to search for an existing item in a menu.

This class is not intended for direct use, but through subclasses. Subclasses should implement at least the following methods:

  • addSeparator()

  • insertSeperator(before)

  • addAction(text,action)

  • insertAction(before,text,action)

  • addMenu(text,menu)

  • insertMenu(before,text,menu)

QtWidgets.Menu and QtWidgets.MenuBar provide these methods.

class gui.menu.Menu(title='UserMenu', parent=None, before=None, tearoff=False, items=None)[source]

A popup/pulldown menu.

class gui.menu.MenuBar(title='TopMenuBar')[source]

A menu bar allowing easy menu creation.

class gui.menu.DAction(name, icon=None, data=None, signal=None)[source]

A DAction is a QAction that emits a signal with a string parameter.

When triggered, this action sends a signal (default ‘CLICKED’) with a custom string as parameter. The connected slot can then act depending on this parameter.

class gui.menu.ActionList(actions=[], function=None, menu=None, toolbar=None, icons=None, text=None)[source]

Menu and toolbar with named actions.

An action list is a list of strings, each connected to some action. The actions can be presented in a menu and/or a toolbar. On activating one of the menu or toolbar buttons, a given signal is emitted with the button string as parameter. A fixed function can be connected to this signal to act dependent on the string value.