visibilityPV

Guide

With EDM the visibilityPV property is often used to control the whether or not a widget is visible. PyDM widgets do not have a specific property for a visibility controlled by a Channel. Instead, PyDM offers a more powerful capability called Rules in which one or more PVs can be used along with an expression to control certain properties at widgets.

For now, most PyDM widgets allow users to control the following properties via Rules:

  • Enable

  • Visible

  • Opacity

  • Position - X*

  • Position - Y*

Note

Properties marked with * may not be available at all widgets.

Some widgets offer more properties than others due to the significance of the property to the widget and whether or not it makes sense to allow dynamic modification of the property via an expression which depends of one or more PyDMChannels.

Example

For this screen, we want to control the visibility of a PyDMDrawingCircle using a PV EDM2PYDM:VIS:CONTROL) and make the circle widget visible when the PV value is equal to 1.

Note

This example uses an EPICS database with simulated PVs which can be downloaded at the end of this page.

  • Step 1.

    Let’s start by opening Qt Designer and creating a new Widget.

    ../_images/new_widget.gif
  • Step 2.

    Now that we have our form, let’s go ahead and add the Widgets.

  • Step 2.1

    The first widget that we will add is the PyDMEnumButton that will control our PV.

    1. Drag and drop a PyDMEnumButton into the form created at Step 1.

    2. Set the channel property to ca://EDM2PYDM:VIS:CONTROL.

  • Step 2.2

    Let’s add the circle drawing widget which will have its visibility controlled via the PV.

    1. Drag and drop a PyDMDrawingCircle next to the PyDMEnumButton added at Step 2.1.

    2. Right-click on the circle widget and select Edit rules....

    3. Click the Add Rule button.

    4. Set the Rule Name field to Visibility Demo.

    5. Select Visible at the property drop down menu.

    6. Click Add Channel.

    7. At the table bellow fill the Channel 0 with: ca://EDM2PYDM:VIS:CONTROL

    8. Leave the trigger checkbox marked as we want the rule to be calculated every time the Channel value changes.

    9. Set the expression field to: ch[0] == 1.

    10. Click Save.

  • Step 3.

    Save your file (suggested name as visibilityPV.ui) and test the example above.

    In one terminal run the example EPICS database:

    softIoc -d visibilityPV.db
    

    In another terminal run the example Display:

    pydm visibilityPV.ui
    

    Once you click at the button and switch from Visible to Invisible you will notice that the circle disappears.

    ../_images/visibilityPV.gif

Note

You can download the UI file using this link and the EPICS db file using this other link.