Access

  • Customizer → Module Customizer → Modules → Macros

Information

  • In the Python Macro module, the existing module Python macro can be edited or, in case it does not exist yet, you can create a new macro.
  • Python macros can be customized by means of the functions in the Python API or standard Python functions.

 As an alternative to Python macros, PLANTA offers the more modern module subclass technology and recommends to use them instead of Python macros.

Procedure

  • Open the required module in the Modules module.
  • Click on the Edit macro button (at the right margin of the module header).
    • The Python Macros module is opened.
      • If a Python macro already exists, it can be edited. Therefore, see the Python API.
      • If there is no Python macro in the module yet, click on the Insert template button which causes a template macro to be copied in automatically.
#MacroTemplate

mod_obj = ppms.get_target_module()

def on_load():
    pass

def on_initial_focus():
    mod_obj.menu(11)

def on_focus():
    pass

def on_reset():
    on_initial_focus()

def on_before_mv_switch(old_mv, new_mv):
    pass

def on_after_mv_switch(old_mv, new_mv):
    pass
PY

Buttons

  • Insert template: inserts a default macro (see the procedure above).
  • SQL : opens the statement entered in the PY macro of the module in the SQL Statements module. The statement can be edited here.
  • MSG: opens the dialog message(s) entered in the PY macro of the source DI in the Dialog Messages module. The dialog message(s) can be edited here.
  • CONST: opens the text constant entered in the PY value range of the source DI in the Text Constants module. The text constant(s) can be edited here.

Note

  • The Python macro of a module can also be opened and edited from the Modules module via the Edit Python macro button in an editor stored in the Global Settings.
  • If a module has a Python macro and macro lines, only the Python macro will be executed.