Simple Python code to generate OPI files for CS-Studio.
Assemble an OPI file by creating widgets. The root widget should be a Display object. Top-level widgets should be added as children of the root widget. You would usually create functions to help create common widgets in your displays.
To write the OPI file out, use a renderer from the renderers package.
Any public attribute of a widget object will become a sub-element in XML with the attribute as tag name. Any simple XML tag can be created by giving the object the correct variable with the correct value. To find out what attributes you need, create the widget in CS-Studio and then examine the XML that is created when you save the file.
Complicated sub-elements, such as rules and actions, can be created using the classes in the opimodel package.
Examples of the use of the cssgen library are included in the examples folder:
examples/basic.py
)To create another type of widget, extend the class Widget
in
opimodel/widgets.py
.
Use a virtualenv:
virtualenv --no-site-packages venv
source venv/bin/activate
pip install -r requirements.txt
export PYTHONPATH=$(pwd)
py.test --cov=renderers --cov=opimodel test