Convert an Existing EDM Screen to a PyDM Screen

In this section we will go over an existing EDM screen and try to convert it to a PyDM screen.

Note

There are multiple ways one can go about designing a screen in PyDM, therefore in this Walk-through we will merely cover a particular approach but please be aware that there could be other approaches that are better or simply more convenient for you.

Let’s start with the screen that we want to convert:

../_images/screen.PNG

The first steps that we want to take when converting an EDM screen, is to go in Edit mode on the EDM screen and inspect what types of widgets we have so that we know what widgets we should be using in PyDM.

To do this, middle click on the EDM screen and select Edit – see highlighted in blue in the image below:

../_images/edm_edit_mode.png

Now you can inspect individual widgets’ properties by left clicking on the widget you want to inspect.

Window Title and Properties

EDM - Title

Middle click on the background of the window and select Display Properties:

../_images/edm_display_properties.png

In the Title of the window’s properties, you can see that we use a macro $(DEV), we want to do the same in PyDM.

PyDM - set Title

When selecting the window (in the work area) you will get on the right side of the Qt Designer, the properties of the window. Scrolling down in the properties area you will see one called windowTitle – change the default name (Form) to a custom name.

../_images/pydm_window_properties.png

Important

In PyDM we define macros with curly brackets instead of parenthesis, e.g.: ${DEV}

EDM - window dimensions

../_images/edm_window_dimensions.png

PyDM - set window dimensions

From the Properties area, go to the Width and Height properties and change them accordingly:

../_images/pydm_window_dimensions.png

Now let’s save the File in PyDM! Type Ctrl+s and give the window a proper name, in this case we’ll name it the same way as the edm screen:

../_images/save.png

For a quick check, you can try to open the .ui file now with PyDM:

pydm -m “DEV=PV:NAME:HERE” mgnt_unit2.ui

Note

When we open an .ui file with PyDM we pass in macros using -m followed by the macros’ definition.

EDM - toggle title

Change the window title to display the path to the file - middle click on the window and select Toggle Title:

../_images/edm_toggle_title.png

PyDM - toggle title - View File Path

Change the window title to display the file location – when the window is open go to View -> Show File Path in Title Bar:

../_images/pydm_view_file_path.png

Static Text

EDM

Static Text Example in EDM, looking at the Magnet Device Display text:

../_images/edm_magnet_display_text.png

Some of its properties:

../_images/edm_magnet_display_properties.png

PyDM

For Static Text in PyDM use a QLabel. Drag and drop a QtLabel:

../_images/qlabel.png

Double click on the label to edit the text, or change it from the properties on the right:

../_images/qlabel_text.PNG

From properties on the left also change the dimensions as well as the position:

../_images/qlabel_prop.png

Scroll down in the properties area and change the font if you need/want to by clicking on the button next to font as highlighted in blue below.

../_images/font.png

Note

You might not find all the Fonts that we have in EDM, for simplicity, using the default one is best. Be aware that some fonts might be larger or smaller, and some adjustment of widgets’ dimensions might be needed because of that.

We’ll get a window where we can change more font-specific properties:

../_images/font_prop.png

By default, a QLabel will not have a background color so in this case we don’t need to worry about setting the background color to match the banner color (not yet at least), but if we need to add a color to the label widget we would follow the same steps as we did for the QFrame: Right click on the label, go to Change styleSheet and choose a background color for example:

../_images/qlabel_color.png

EDM - static text with Macro

Notice the macro in this text: $(DEV)

../_images/edm_text_with_macro.png

PyDM - text with Macro

Drag and drop a QLabel, add a macro - ${DEV}:

../_images/pydm_text_with_macro.png

Text Control – Non-Editable

EDM

Example of Control Text highlighted below in blue:

../_images/edm_control_text_non.png

Some properties:

../_images/edm_control_text_prop.png

PyDM

Use a PyDMLabel for a non-editable Control Text in PyDM. Drag and drop a PyDMLabel. Go through the same process as for a Static Text with changing the dimensions, position, and font (if needed). Expend the font to make it bold from the font down arrow properties:

../_images/bold_font.png

Note the extra properties of a PyDMLabel if you scroll all the way down in the properties area (compared to the QLabel).

Most of the times you will leave default properties for these labels. Note the channel property – here is where you would insert a PV.

../_images/pydmlabel_prop.png

Let’s add a PV:

../_images/add_pv.png

Important

PVs start with ca:// in PyDM.

Note

If we don’t have Qt Designer set to be “Online” we will not see the PVs’ values in QtDesigner. To set the Qt Designer online we need to export this variable to 1:

export PYDM_DESIGNER_ONLINE=1

The banner is done, please note that by default every screen in PyDM will come with similar buttons as in EDM, so there are no widgets for these below, but if we want to add an additional button that will give users more information about the screen, we can add a PyDM Related Display button and we’ll cover how to this later in this walk-through.

../_images/banner_buttons.png ../_images/banner_done.PNG

In PyDM all screens will have this set of menus:

../_images/menu.png

Click on File to get more options and find out more about PyDM:

../_images/about_pydm.png

Please explore the other menu information and options.

Note

The PyDM menu on top of the screens will add some height to the screen.

Grouping Things Together

EDM

In this example EDM is using a Rectangle and a Static Text to form an area.

../_images/edm_group_together.png

PyDM

In PyDM there are multiple ways to go about grouping things together esthetically. You could use a QLabel and a Frame to imitate what we have in EDM, but for simplicity we’ll use a different widget called QGroupBox – this one already has a text in it and a shaded frame area by default:

../_images/group_box.png

Double click on the GroupBox text to change the text and change the dimensions from the properties on the right.

Warning

Note that when using the QGroupBox (or a Frame), the X and Y will reset to 0, 0 from the QGroupBox, so you’ll have to account for that when adding widgets in the box, if you don’t want to account for that and want to match the X and Y positions as close as possible to EDM’s widgets, add the GroupBox at the end after you are done adding the widgets.

For example if we wore to skip ahead and add a QGroupBox at the end, simply drag and drop a GroupBox on top of what you want to group (this is just an example):

../_images/group_with_group_box.PNG

You can also right click on it and send it to back so you can access the widgets in it freely:

../_images/send_to_back.PNG

You can do a similar thing with a Frame, just drag and drop a Frame and stretch it so it covers the group area:

../_images/group_with_frame.PNG

Meter Widget

EDM

../_images/meter_widget.png

PyDM:

In PyDM we do not have a Meter Widget - we have a similar widget we can use, but the design is a bit different, in the sense that it is not circular, here we can use a PyDMScaleIndicator widget:

../_images/scale_indicator.png

Change the dimensions and properties as we previously did with other widgets, add PV:

../_images/scale_indicator_pv.png

Take off the precisionFromPV option and add a precision value of 2:

../_images/scale_indicator_precision.png

Change the color of the indicator if desired:

../_images/scale_indicator_color.png

You can also get a feel of how it would look in Preview Mode, go to Form and select Preview:

../_images/preview_mode.png

Now if you like how it looks, you can copy and paste it to get the second one. Select the widget, Ctrl+c to copy it, and Ctrl+v to paste it. You will have to adjust the position for the second one and change the PV.

Note that this widget does not have a label, so let’s add a simple QLabel. Place a label right below the widget and make sure it has the same width, as well as it starts at the same X as the scale widget, and at Y + height of scaleIndicator for Y position:

../_images/scale_indicator_label.png

Additionally, you can give both these widgets a background color if wanted - to look like they are part of one widget (simulating EDM), just right click on the widget and select Change stylesheet to add a background-color and a border-color for both. Here is how they would approximately look:

../_images/scale_indicator_grey.png

Note

You can choose a color by picking directly one around your work area by selecting the Pick Screen Color. This is useful when you don’t remember what color you used previously but want them to match with a color you already chose previously - see below:

../_images/pick_screen_color.png

Text Control – Editable- Motif Widget

EDM

Proceeding with the next section on our screen, we have a widget Text Control that is in Editable mode highlighted in blue below:

../_images/control_text_editable.png

PyDM

In PyDM, we use a PyDMLineEdit for a Text Control that is Editable (you can write in it):

../_images/edit_line.png

It will have similar and additional properties as a PyDMLabel.

  • Note how I added the the other labels, we already covered those labels in this walk-through above. If you need to change one thing for multiple widgets of the same type, you can select all of them (mouse drag or Ctrl+left click) and change it for all at once, for example I took out the alarmSensitiveBorder property Off from the EGU labels:

Select all those labels (Ctrl+right click on the widget):

../_images/egu_labels.png

Uncheck the alarmSensitiveBorder box, unchecking only once will uncheck for all those selected widgets:

../_images/uncheck.png

One thing that I also had to go back and do was to change the Display Format for some label widgets, you can do it by selecting multiple widgets again and change the property of the dispalyFormat to what the EDMs are - in this case I changed them from Default to String:

../_images/display_format.png

Slider

EDM

In the next section we meet a new widget that we have not discussed previously, the Motif Slider:

../_images/motif_slider.png

PyDM

In PyDM we have a similar widget called PyDMSlider – drag and drop one in the new QControlBox (note we created a new QControlBox rather than doing that at the end as explained previously):

../_images/slider.png

Let’s adjust some properties, let’s change precision to 4 and take out the precisionFromPV, aslo let’s add a channel PV:

../_images/slider_prop.png

Let’s also add a label on top of this widget to imitate what we have in EDM:

../_images/slider_label.png

Message Button - Push Button

EDM

The Message Button in EDM:

../_images/edm_push_button.png

Properties.

Notice here the Visibility PV:

../_images/edm_push_button_prop.png

PyDM

In PyDM we would use a PyDMPushButton for this type of widget:

../_images/pydm_push_button.PNG

In our case we might want to change a few main properties like: text, channel, pressValue, releaseValue, and maybe others.

../_images/push_button_prop.png

For the Visibility PV we would handle it this way in PyDM - Right click on the widget and select Edit Rule:

../_images/edit_rules.png

You will get a new little window where you will need to:

  • click on Add Rule

  • give it a Rule name

  • add the channel PV

  • define the condition

If you look at the EDM condition, it says Not Visible if the PV value >= 1 and < 2. We will have to modify the condition to be true for Visible if instead:

../_images/rule.png

Save it when you are ready.

Note

For the 3 buttons I applied the same rule, so I was able to select all three buttons and just type the rule ones – this was applied for all 3.

Horizontal Bar

EDM

Horizontal Bar in EDM and its properties:

../_images/horizontal_bar.png

PyDM

In PyDM we can use the PyDMScaleIndicator for this type of widget:

../_images/scale_indicator.png

Note, we should check the barIndicator for it to look like a progress bar, Also, we can change the indicatorColor to be green, and take the showTicks off:

../_images/bar_indicator.png

By default this scale indicator will be horizontal, but we can change the orientation to Vertical if we need to.

We can also take the showLimits off to be more consistent with the EDM widget, as well as showValue off, and let’s also check the originAtZero box:

../_images/bar_prop.png

Note

In Qt Designer it will not show the green progress indicator unless we are reading that PV and it has a value in it.

Let’s also add a label:

../_images/bar_label.png

Choice Button

EMD

Choice button in EDM in Edit mode:

../_images/edm_choice_edit.png

Choice button in EDM in Exec mode:

../_images/edm_choice_exec.png

Properties:

../_images/choice_prop.png

PyDM

In PyDM we would use a PyDMEnumButton for this widget:

../_images/enum_button.PNG

Properties - please note that besides changing the width and height, we should take off the alarmSensitiveBorder, insert the channel, change the orientation to Horizontal, and set the margins settings all to 2 so there is little space between the buttons – imitating the EDM widget:

../_images/enum_prop.png

Rectangles - Frames

EDM

In EDM we have rectangles that let us visually separate sections:

../_images/edm_rectangle.png

PyDM

In PyDM we can accomplish the same thing with a QFrame:

../_images/frame.png

Adjust the width and height and copy and paste the frame to reuse it. You can also change the style of these frames by choosing a different frameShape:

../_images/frame_shape.png

Here we chose a Box and also set the frameShodow to Plain and lineWidgth to 2:

../_images/frame_prop.png

This is approximately how it will look:

../_images/frames.png

We can also take a different approach here, and instead of creating three boxes, we could create one and add some horizontal lines, and from the properties give them different thickness to be more pronounced if needed.

../_images/horizontal_line.PNG

Visibility Frame

EDM

Note that we have a Group Box in EDM that has a rule for visibililty:

../_images/edm_visibility_frame.png

PyDM

We can acomplish the same thing with PyDM by using a PyDMFrame:

Drag and drop a PyDMFrame:

../_images/visibillity_frame.png

Add the rule:

../_images/visibility_rule.png

And then start placing the Labels and Radio Buttons in the frame:

../_images/place_in_frame.png

Radio Button

EDM

Radio Button in EDM:

../_images/edm_radio_button.png

Note if more widgets are in a Group Box, you’ll have to middle click and select Ungroup for all the groups until you get to the Radio Box:

../_images/edm_group_box.png

Properties of the Radio Box:

../_images/radio_box_prop.png

PyDM

In PyDM we will use a PyDMEnumButton for this widget as well:

../_images/enum_button.PNG

Set the widgetType to RadioButton:

../_images/radio_button.png

Also change the margins from 9 to probably a smaller value, except you want to have some distance vertically between them, so leave the verticalSpacing to 9.

../_images/vertical_space.png

Besides inserting the channels, some of these radio buttons have a rule - to be invisible when a condition is met, so let’s select all the widgets that will have this rule (the rule is the same for all in this case) and add it in: Select all radio button widgets that will have the rule. You can select them with holding down Ctrl and clicking on the widget with the mouse:

../_images/radio_button_rule.png

Add the rule by right clicking and choosing Edit Rule:

../_images/radio_button_add_rule.png

Note

For the labels where the text does not fit on one line, I had to check the wordWrap property option.

../_images/word_wrap.PNG

Embeded Display

EDM

The last portion on this screen that we have not covered yet is the Embedded Display, looking at the properties, we see that this embedded display is opening a file highlighted below:

../_images/embeded_widndow.PNG

Notice that we’re using a macro here $(DISP) - if you are unsure of what this macro represents and you have to specify that in a PyDM embedded display, you can see the macros by right-clicking on the widget, and choose Show Macros

Also, if we need to investigate the Related Display Buttons a little further, we could open the actual edm screen from the terminal and look at the properties of those buttons:

edm mgnt_unit_epcs.edl

This will open the following window in Edit mode, so we can click on each widget to see their properties:

../_images/open_edl_screen.PNG

PyDM

In PyDM we’ll have to create that file first. Go to File -> New and create a new Widget, set the width and height to correspond to the ones seen in the EDM Embedded Display properties.

../_images/new_file.PNG

Notice that in the EDM Embedded Display we have 4 Related Display Buttons, let’s recreate them in PyDM. We’ll be using a widget we already covered previously - the PyDMEDMDisplayButton to open existing edm displays, thus we will not go into too many details here. Open the displays by clicking on the EDM buttons (from the EDM screen) to see what files we need to open with the Related Display widgets by looking at the Toggle Path option as previously explained, so we can add those file names and their paths to our PyDMEDMDisplayButton widgets.

Add their file names:

../_images/edm_display_buttons.PNG

Preview:

../_images/epsc_file.PNG

Note

Make sure you check the openInNewWindow option for each button!

One thing to notice here is that two of the buttons for the Related Displays have a green border, this was added in EDM with a simple Rectangle that has a green order and has a PV associated with it. In PyDM we can add the same with a PyDMFrame, just drag and drop a PyDMFrame, adjust the size, then select the button and bring it inside the frame!! - if you already placed the button on the screen you’ll have to move it a bit from its location and bring it back so it goes inside the frame - this is important!

../_images/pydm_frame.PNG

Make sure to check the alarmSensitivityBorder and add the channel:

../_images/alarm_frame.PNG

Now that we have this file created, let’s go back to our main screen and add a PyDmEmbeddedDisplay widget:

../_images/pydm_embeded_display.PNG

Let’s add the file name that we just created, and because they are in the same folder, no additional paths need to be included in the filename properties, only the file name itself.

You’ll notice that as soon as you add the filename the display we created previously will appear on the main screen:

../_images/embeded_display.PNG

Note

If the display is not showing up, make sure the path of the file relative to the current screen is correct!

This concludes all the widgets on this screen - go to the next section for some touch up and stylesheets!! And this is approximately how it looks now:

../_images/approximate.PNG

Note

Some of the widgets are disabled because we only have Write-Only access.