67. plugins — pyFormex plugins initialisation.

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

67.1. Classes defined in module plugins

class plugins.PluginMenu(name, modname=None, package='pyformex.plugins')[source]

A registered reloadable plugin menu.

A plugin menu is a Python module living in an accessible package. The default package is pyformex.plugins. The module should define a function create_menu(before='help'). This function should create and return a Menu created as follows:

menu.Menu(name, menu_items, parent=pf.GUI.menu, before=before)

Here name is the displayed menu name and menu_items is the list of items in the menu. The menu should be a child of the main pyFormex menu, and be inserted before the Help menu (or a preceding menu).

The plugin module can also define a function on_reload(). If so, this function will be called when the plugin is reloaded.

The plugin menu should then be registered by creating a PluginMenu instance.

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.plugins’.

load()[source]

Load the plugin menu

refresh()[source]

Reload the plugin module

show(before='help')[source]

Show the menu.

close()[source]

Close the menu.

reload()[source]

Reload 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_menu’ can be displayed as ‘Geometry Menu’).

67.2. Functions defined in module plugins

plugins.loadConfiguredPlugins(ok_plugins=None)[source]

Load or unload plugin menus.

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