6. Extendable Python module templates

Four Python modules are intended to extend the functionality of the application:

  • event – event handling;
  • menu – adding user menus;
  • logon – log on Cerebro;
  • logoff – log off Cerebro.

The templates of these modules can be found in the py-frontend folder and they are named accordingly:

  • action.py.template
  • event.py.template
  • logon.py.template
  • logoff.py.template

Rename a file to {name}.py to use this or that extension. For example:

action.py.template -> action.py

The module templates contain the functions called from the application in a certain moment. The code executed on function call is written in the function body.

For example, the action.py.template template has the def action.init_actions() function. To add a user menu, you have to:

  1. Rename action.py.template into action.py
  2. Enable user modules, if necessary
  3. Write the necessary code in the body of the init_actions function

action.py:

import examples # Import examples package

def init_actions():
    # Call function to adding user-defined menus
    examples.action.main()