BcdaQWidgets: bcdaqwidgets.bcdaqwidgets

BcdaQWidgets: PyEpics-aware PyQt widgets for the APS

Copyright (c) 2009-2017, UChicago Argonne, LLC. See LICENSE file for details.

The bcdaqwidgets [1] module provides a set of PyQt4 widgets that are EPICS-aware. These include:

widget description
BcdaQLabel EPICS-aware QLabel widget
BcdaQLineEdit EPICS-aware QLineEdit widget
BcdaQPushButton EPICS-aware QPushButton widget
BcdaQMomentaryButton sends a value when pressed or released, label does not change
BcdaQToggleButton toggles boolean PV when pressed
BcdaQLabel_RBV makes motor RBV field background green when motor is moving
[1]BCDA: Beam line Controls and Data Acquisition group of the Advanced Photon Source, Argonne National Laboratory, http://www.aps.anl.gov/bcda

Note

bcdaqwidgets must be imported AFTER importing PyQt4

class bcdaqwidgets.bcdaqwidgets.BcdaQLabel(pvname=None, useAlarmState=False, bgColorPv=None)[source]

Provide the value of an EPICS PV on a PyQt4.QtGui.QLabel

USAGE:

import bcdaqwidgets

...

widget = bcdaqwidgets.BcdaQLabel()
widget.ca_connect("example:m1.RBV")
Parameters:
  • pvname (str) – epics process variable name for this widget
  • useAlarmState (bool) – change the text color based on pv severity
  • bgColorPv (str) – update widget’s background color based on this pv’s value
SetBackgroundColor(*args, **kw)[source]

set the background color of the widget via its stylesheet

SetBackgroundColorExtra(*args, **kw)[source]

changes the background color of the widget

onBgColorObjChanged(*args, **kw)[source]

epics pv callback when bgColor PV changes

class bcdaqwidgets.bcdaqwidgets.BcdaQLabel_RBV(*args, **kw)[source]

makes motor readback field (BcdaQLabel) background green when motor is moving

EXAMPLE:

pvname = 'ioc:m1'
w = bcdaqwidgets.BcdaQLabel_RBV()
layout.addWidget(w)
w.ca_connect(pvname+'.RBV')
ca_connect(rbv_pv)[source]
dmov_callback(*args, **kw)[source]

called in PyEpics thread

setBackgroundColor(value)[source]

called in GUI thread

class bcdaqwidgets.bcdaqwidgets.BcdaQLineEdit(pvname=None, useAlarmState=False)[source]

Provide the value of an EPICS PV on a PyQt4.QtGui.QLineEdit

USAGE:

import bcdaqwidgets

...

widget = bcdaqwidgets.BcdaQLineEdit()
widget.ca_connect("example:m1.VAL")
SetBackgroundColor(*args, **kw)[source]

set the background color of the QLineEdit() via its QPalette

onReturnPressed()[source]

send the widget’s text to the EPICS PV

class bcdaqwidgets.bcdaqwidgets.BcdaQMomentaryButton(label='', pvname=None, pressed_value=None, released_value=None)[source]

Send a value when released, label does not change if PV changes.

It only acts on mouse pressed signal.

This is a special case of a BcdaQPushButton where the text on the button does not respond to changes of the value of the attached EPICS PV.

It is a good choice to use, for example, for a motor STOP button.

USAGE:

import bcdaqwidgets

...

widget = bcdaqwidgets.BcdaQMomentaryButton('Stop')
widget.ca_connect("example:m1.STOP")
widget.SetPressedValue(1)
onPressed(**kw)[source]

button was pressed, send preset value to EPICS

class bcdaqwidgets.bcdaqwidgets.BcdaQPushButton(label='', pvname=None, pressed_value=None, released_value=None)[source]

Provide a QtGui.QPushButton connected to an EPICS PV

It is necessary to also call the SetPressedValue() and/or SetReleasedValue() method to define the value to be sent to the EPICS PV with the corresponding push button event. If left unconfigured, no action will be taken.

USAGE:

import bcdaqwidgets

...

widget = bcdaqwidgets.BcdaQPushButton()
widget.ca_connect("example:bo0")
widget.SetReleasedValue(1)
SetBackgroundColor(*args, **kw)[source]

set the background color of the QPushButton() via its stylesheet

SetPressedValue(value)[source]

specify the value to be sent to the EPICS PV when the button is pressed

SetReleasedValue(value)[source]

specify the value to be sent to the EPICS PV when the button is released

onPressed(**kw)[source]

button was pressed, send preset value to EPICS

onReleased(**kw)[source]

button was released, send preset value to EPICS

class bcdaqwidgets.bcdaqwidgets.BcdaQSignalDef[source]

Define the signals used to communicate between the PyEpics thread and the PyQt4 (main Qt4 GUI) thread.

class bcdaqwidgets.bcdaqwidgets.BcdaQToggleButton(pvname=None)[source]

Toggles boolean PV when pressed

This is a special case of a BcdaQPushButton where the text on the button changes with the value of the attached EPICS PV. In this case, the displayed value is the name of the next state of the EPICS PV when the button is pressed.

It is a good choice to use, for example, for an ON/OFF button.

USAGE:

import bcdaqwidgets

...

widget = bcdaqwidgets.BcdaQToggleButton()
widget.ca_connect("example:room_light")
widget.SetReleasedValue(1)
SetText(*args, **kw)[source]

set the text of the widget (threadsafe update) from the EPICS PV

ca_connect(pvname, ca_callback=None, ca_connect_callback=None)[source]
onPressed()[source]

button was pressed, toggle the EPICS value as a boolean

class bcdaqwidgets.bcdaqwidgets.BcdaQWidgetSuper(pvname=None, useAlarmState=False)[source]

superclass for EPICS-aware widgets

SetText(text, *args, **kw)[source]

set the text of the widget (threadsafe update)

ca_connect(pvname, ca_callback=None, ca_connect_callback=None)[source]

Connect this widget with the EPICS pvname

Parameters:
  • pvname (str) – EPICS Process Variable name
  • ca_callback (obj) – EPICS CA callback handler method
  • ca_connect_callback (obj) – EPICS CA connection state callback handler method
ca_disconnect()[source]

disconnect from this EPICS PV, if connected

onPVChange(pvname=None, char_value=None, **kw)[source]

respond to a PyEpics camonitor() event

onPVConnect(pvname='', **kw)[source]

respond to a PyEpics CA connection event

updateStyleSheet(changes_dict)[source]

update the widget’s stylesheet

bcdaqwidgets.bcdaqwidgets.RBV_BcdaQLabel

alias of BcdaQLabel_RBV

class bcdaqwidgets.bcdaqwidgets.StyleSheet(widget, sty={})[source]

manage style sheet settings for a Qt widget

Example:

widget = QtGui.QLabel('example label')
sty = bcdaqwidgets.StyleSheet(widget)
sty.updateStyleSheet({
    'font': 'bold',
    'color': 'white',
    'background-color': 'dodgerblue',
    'qproperty-alignment': 'AlignCenter',
})
clearCache()[source]

clear the internal cache

updateStyleSheet(sty={})[source]

change specified styles and apply all to widget

bcdaqwidgets.bcdaqwidgets.typesafe_enum(*sequential, **named)[source]

typesafe enum

EXAMPLE:

>>> Numbers = typesafe_enum('ZERO', 'ONE', 'TWO', four='IV')
>>> Numbers.ZERO
0
>>> Numbers.ONE
1
>>> Numbers.four
IV
See:http://stackoverflow.com/questions/36932/whats-the-best-way-to-implement-an-typesafe_enum-in-python