OPI Model package

opimodel.actions

class opimodel.actions.ActionsModel(hook_first=True, hook_all=False)[source]

Bases: object

Represents all actions attached to a widget.

add_action(action)[source]
get_hook_all()[source]
get_hook_first()[source]
set_hook_all(hook_all)[source]
set_hook_first(hook_first)[source]
class opimodel.actions.ExecuteCommand(command, description, directory='$(opi.dir)')[source]

Bases: object

Action that executes a script command in the specified directory.

HOME_DIR = '$(user.home)'
OPI_DIR = '$(opi.dir)'
class opimodel.actions.Exit[source]

Bases: object

Action that closes the current opi.

class opimodel.actions.OpenOpi(path, mode=8, macros=None, parent_macros=True)[source]

Bases: object

Action that opens another opi file.

DETACHED_TAB = 6
NEW_WORKBENCH = 7
REPLACE_CURRENT = 0
STANDALONE = 8
WORKBENCH_TAB = 1
WORKBENCH_TAB_BOTTOM = 5
WORKBENCH_TAB_LEFT = 2
WORKBENCH_TAB_RIGHT = 3
WORKBENCH_TAB_TOP = 4
get_macros()[source]

Get the macros dict.

Returns:
dict: the macros dict
get_parent_macros()[source]

Get whether parent macros should be inherited.

Returns:
boolean: whether parent macros should be inherited
class opimodel.actions.WritePv(pv, value, description='')[source]

Bases: object

Action that writes the specified value to a named PV.

opimodel.borders

class opimodel.borders.Border(style, width, color, alarm)[source]

Bases: object

opimodel.colors

class opimodel.colors.Color(rgb=(0, 0, 0), name=None)[source]

Bases: object

Representation of a color.

opimodel.colors.parse_css_color_file(filepath)[source]
Parse the provided color.def file, create Color objects for each
defined color and attach them to the namespace of this module wth names converted into appropriate constants by the utils.mangle_name() function.
Args:
filepath of the color file

opimodel.fonts

class opimodel.fonts.Font(name=None, fontface='Liberation Sans', size=15, style=0, pixels=True)[source]

Bases: object

Representation of a font.

opimodel.fonts.parse_css_font_file(filename)[source]
Parse the provided font.def file, create Font objects for each
defined font and attach them to the namespace of this module wth names converted into appropriate constants by the utils.mangle_name() function.
Args:
filepath of the font file

opimodel.rules

class opimodel.rules.BetweenRule(prop_id, pv, min_val, max_val, min_equals=True, max_equals=True, name=None)[source]

Bases: opimodel.rules.Rule

class opimodel.rules.GreaterThanRule(prop_id, pv, threshold, name=None, val=True, false_val=False, sevr_options=None)[source]

Bases: opimodel.rules.Rule

class opimodel.rules.RawRule(prop_id, rule_xml, name=None)[source]

Bases: opimodel.rules.Rule

class opimodel.rules.Rule(prop_id, name=None)[source]

Bases: object

get_name()[source]
get_prop_id()[source]
class opimodel.rules.SelectionRule(prop_id, pv, name=None, val_options=None, sevr_options=None, else_val=None)[source]

Bases: opimodel.rules.Rule

opimodel.utils

opimodel.utils.add_attr_to_module(name, value, module)[source]
Attach value to the namespace of module with a names converted
into appropriate an constant by the mangle_name() function.
Args:
name to be converted and used value to be assigned module to attach the value to
opimodel.utils.mangle_name(name)[source]
Convert the name found in a color or font configuration file into
a Python variable:
  • convert to upper-case
  • replace non-letters with underscores
  • avoid consecutive underscores
Args:
name to convert
Returns:
converted name

opimodel.widgets

Module containing widgets to describe opi files. An opi has a root widget of type Display. To create the opi, add widgets as children of this widget.

class opimodel.widgets.ActionButton(x, y, width, height, text, hook_first=True, hook_all=False)[source]

Bases: opimodel.widgets.ActionWidget

TYPE_ID = 'org.csstudio.opibuilder.widgets.ActionButton'
class opimodel.widgets.ActionWidget(type_id, x, y, width, height, hook_first=True, hook_all=False)[source]

Bases: opimodel.widgets.Widget

Base class for any widget that can have a list of actions.

add_action(action)[source]

Add any action to the list of actions.

Args:
action to add
add_exit()[source]
add_open_opi(path, mode=8, macros=None, parent_macros=True)[source]
add_shell_command(command, description='', directory='$(opi.dir)')[source]
add_write_pv(pv, value, description='')[source]
class opimodel.widgets.Byte(x, y, width, height, pv, bits, start_bit=None)[source]

Bases: opimodel.widgets.Widget

TYPE_ID = 'org.csstudio.opibuilder.widgets.bytemonitor'
class opimodel.widgets.Display(width, height)[source]

Bases: opimodel.widgets.Widget

Display widget. This is the root widget for any opi.

TYPE_ID = 'org.csstudio.opibuilder.Display'
add_scale_options(min_width=-1, min_height=-1, autoscale=False)[source]

Add scale options to the display.

Args:
min_width (int): Display min width, -1 for no scaling min_height (int): Display min height, -1 for no scaling autoscale (bool): Autoscale child widgets
class opimodel.widgets.GroupingContainer(x, y, width, height)[source]

Bases: opimodel.widgets.Widget

TYPE_ID = 'org.csstudio.opibuilder.widgets.groupingContainer'
class opimodel.widgets.HAlign[source]

Bases: object

Enum describing horizontal alignment

This is typically used with the horizontal_alignment property.

CENTER = 1
LEFT = 0
RIGHT = 2
class opimodel.widgets.Label(x, y, width, height, text)[source]

Bases: opimodel.widgets.Widget

TYPE_ID = 'org.csstudio.opibuilder.widgets.Label'
class opimodel.widgets.Led(x, y, width, height, pv)[source]

Bases: opimodel.widgets.Widget

TYPE_ID = 'org.csstudio.opibuilder.widgets.LED'
class opimodel.widgets.Line(x0, y0, x1, y1)[source]

Bases: opimodel.widgets.Widget

ID = 'org.csstudio.opibuilder.widgets.polyline'
class opimodel.widgets.MenuButton(x, y, width, height, text)[source]

Bases: opimodel.widgets.ActionWidget

TYPE_ID = 'org.csstudio.opibuilder.widgets.MenuButton'
class opimodel.widgets.Rectangle(x, y, width, height)[source]

Bases: opimodel.widgets.ActionWidget

ID = 'org.csstudio.opibuilder.widgets.Rectangle'
class opimodel.widgets.Symbol(x, y, width, height, pv, image_file, image_width, image_index=0)[source]

Bases: opimodel.widgets.ActionWidget

TYPE_ID = 'org.csstudio.opibuilder.widgets.edm.symbolwidget'
class opimodel.widgets.TextInput(x, y, width, height, pv)[source]

Bases: opimodel.widgets.Widget

TYPE_ID = 'org.csstudio.opibuilder.widgets.TextInput'
class opimodel.widgets.TextMonitor(x, y, width, height, pv)[source]

Bases: opimodel.widgets.Widget

TYPE_ID = 'org.csstudio.opibuilder.widgets.TextUpdate'
class opimodel.widgets.ToggleButton(x, y, width, height, on_text, off_text)[source]

Bases: opimodel.widgets.ActionWidget

TYPE_ID = 'org.csstudio.opibuilder.widgets.BoolButton'
add_push_action(action)[source]
add_release_action(action)[source]
class opimodel.widgets.Widget(type_id, x, y, width, height, name='widget')[source]

Bases: object

Base class for any widget to extend.

Args:
id - the CSS id for the widget. x - the x position of the widget in pixels y - the y position of the widget in pixels widget - the width of the widget in pixels height - the height of the widget in pixels name - a name for the widget within the display
add_child(child)[source]

Add a widget as a child of this widget.

Args:
child widget
add_children(children)[source]

Add multiple widgets as children of this widget.

Args:
sequence of child widgets
add_rule(rule)[source]

Add a rule to the widget.

Args:
Rule object
add_scale_options(width=True, height=True, keep_wh_ratio=False)[source]

Add scale options to the widget.

Args:
width (bool): True if widget width is scalable height (bool): True if widget height is scalable keep_wh_ratio (bool):
get_children()[source]

Get all child widgets.

get_name()[source]
get_parent()[source]

Get the parent widget of this widget.

get_type_id()[source]
set_bg_color(color)[source]

Set background color for the widget.

Args:
Color object
set_border(border)[source]

Set border for the widget.

Args:
Border object
set_fg_color(color)[source]

Set background color for the widget.

Args:
Color object
set_font(font)[source]

Set font for the widget.

Args:
Font object
set_parent(parent)[source]

Set the parent widget of this widget.

Args:
widget to be this widget’s parent

Renderer packages

renderers.css.actions

class renderers.css.actions.OpiAction(text_renderer)[source]

Bases: object

Base class for action renderers.

render(actions_node, action_model)[source]
class renderers.css.actions.OpiActions[source]

Bases: object

Renderer for actions.

ACTION_MAPPING = {<class 'opimodel.actions.OpenOpi'>: <class 'renderers.css.actions.OpiOpen'>, <class 'opimodel.actions.ExecuteCommand'>: <class 'renderers.css.actions.OpiExecuteCommand'>, <class 'opimodel.actions.WritePv'>: <class 'renderers.css.actions.OpiWritePv'>, <class 'opimodel.actions.Exit'>: <class 'renderers.css.actions.OpiExit'>}
render(widget_node, tag_name, actions_model)[source]
class renderers.css.actions.OpiExecuteCommand(text_renderer)[source]

Bases: renderers.css.actions.OpiAction

Renderer for write PV actions.

ACTION_TYPE = 'EXECUTE_CMD'
class renderers.css.actions.OpiExit(text_renderer)[source]

Bases: renderers.css.actions.OpiAction

Render for exit OPI actions.

ACTION_TYPE = 'EXECUTE_JAVASCRIPT'
render(actions_node, action_model)[source]

Render an exit action.

Args:
actions_node to be parent of the action action_model representing the exit action
class renderers.css.actions.OpiOpen(text_renderer)[source]

Bases: renderers.css.actions.OpiAction

Renderer for write PV actions.

ACTION_TYPE = 'OPEN_DISPLAY'
MACRO_ERROR = 'Invalid macro {}:{} (error {})'
render(actions_node, action_model)[source]
class renderers.css.actions.OpiWritePv(text_renderer)[source]

Bases: renderers.css.actions.OpiAction

Renderer for write PV actions.

ACTION_TYPE = 'WRITE_PV'

renderers.css.borders

class renderers.css.borders.OpiBorder(text_renderer, color_renderer)[source]

Bases: object

render(widget_node, _, border_model)[source]

renderers.css.colors

class renderers.css.colors.OpiColor[source]

Bases: object

render(widget_node, tag_name, color_model)[source]

renderers.css.fonts

class renderers.css.fonts.OpiFont[source]

Bases: object

render(widget_node, tag_name, font_model)[source]

renderers.css.points

class renderers.css.points.OpiPoints[source]

Bases: object

render(widget_node, tag_name, points_model)[source]

renderers.css.render

class renderers.css.render.OpiRenderer(model, widget_renderer)[source]

Bases: object

assemble(model=None, parent=None)[source]
get_node()[source]
write_to_file(filename)[source]
renderers.css.render.get_opi_renderer(widget)[source]

renderers.css.rules

class renderers.css.rules.OpiRule(text_renderer, color_renderer)[source]

Bases: object

render(widget_node, tag_name, rule_list)[source]

renderers.css.text

class renderers.css.text.OpiText[source]

Bases: object

render(widget_node, tag_name, model)[source]

renderers.css.widget

class renderers.css.widget.OpiWidget(text_renderer)[source]

Bases: object

add_renderer(tag, renderer)[source]
render(model, parent)[source]