Refer to Code that is in a Python Library Item

You can store common Python program code in Python Library items in the Geo SCADA Expert database (see Create and Configure a Python Library Item). You can then refer to that code in your Python programs. To do this, you need to reference the Python Library items that you want to use in two places:

 

An engineer creates a Python Library database item and calls it 'Configuration Functions'.

On the configuration form of the Python Library item, they give it the Module Name of 'GSConfigFunc':

They edit the Python Library item and populate it with the common Python program code that they want to store in that Python Library item.

On the configuration form of each Python Program item that is to use code from that Python Library, they scroll down to the Python Libraries field. They add an entry out to that Python Library database item from the field:

They edit the Python Program to include a line of code to import the Python Library into the program:

Be aware that:

  • The import statement in the code references the Module Name of the Python Library item.

  • The Python Libraries field on the configuration form references the full name (including the path) of the database item in which the Python Library code is stored.

  • You can only reference a Python Library item that is in the same Geo SCADA Expert database as the Python Program item.

Further Information

For detailed sample Python programs, see the Example Projects database.

For information about the classes and functions that you can use in your Python programs, see the separate 'Python client library for Geo SCADA Expert' documentation suite.