76. gui.menus — pyFormex plugin menus.

This module contains the functions to detect and load the pyFormex plugin menus.

76.1. Classes defined in module gui.menus

class gui.menus.PluginMenu(name, *, modname=None, package='pyformex.gui.menus', menuctrl='submenu', persistent=False)[source]

A registered reloadable plugin menu.

A plugin menu is a pull down menu installed in the top menu bar of the GUI. It is defined in a Python module living in an accessible package. The default package is pyformex.gui.menus. The module should define an attribute menu_items which is a list of menu items usable to create a Menu instance.

The plugin module can also define a function menu_setup(menu). If so, this function is called when the plugin menu is (re)loaded. The function takes the created menu as a parameter. It can e.g. be used to enable/disable menu options, to dynamically change the menu contents at runtime, to reset the PluginMenu’s module or for anything you want to be done on reloading the menu.

Creating a PluginMenu creates and registers the menu, but does not automatically show it. Use the show() method to let it appear in the menubar.

See the pyformex.gui.menus pyformex.apps packages for examples.

Parameters:
  • name (str) – The name of the menu. This is the name as appearing in the menu bar. This is normally a single short capitalized word. It should be different from all other plugin menus (unless you want to override another plugin with the same name).

  • modname (str, optional) – The name of the module that contains the plugin menu. The default value is the name converted to lower case and with ‘_menu’ appended.

  • package (str, optional) – The dotted name of the package containing the plugin module. The default is ‘pyformex.gui.menus’.

  • menuctrl (str, optional) – Defines if and how automatic menu control items should be added. A string starting with ‘s’ will insert them as as submenu, a string starting with ‘i’ will insert them inline with the other menu options, any other string will not show the menu control items. The menu control currently contains two items: reload the menu, and close the menu. THe default is to insert them as a submenu.

show(parent=None, before='help', reload=False)[source]

Show the menu.

close()[source]

Close the menu.

classmethod list()[source]

Return a list of registered plugin menus.

Returns:

list of tuple – A list of tuples (name, nicename), where name is the module name of the plugin and Nice Name is the beautified displayed name for user readability. Thus ‘Geometry’ can be displayed as ‘Geometry Menu’).

76.2. Functions defined in module gui.menus

gui.menus.loadConfiguredPlugins(ok_plugins=None, parent=None)[source]

Load or unload plugin menus.

Loads the specified plugins and unloads all others. If None specified, load the user configured plugins.