BcdaQWidgets

PyEpics-aware PyQt widgets for the APS

Note: This project is not complete and may be deleted in the future.
The documentation is being added slowly.
author:Pete R. Jemian
email:jemian@anl.gov
copyright:2005-2017, UChicago Argonne, LLC
license:ANL OPEN SOURCE LICENSE (see LICENSE.txt)
docs:http://bcdaqwidgets.readthedocs.io
git:https://github.com/BCDA-APS/bcdaqwidgets.git
PyPI:https://pypi.python.org/pypi/BcdaQWidgets
TODO list:https://github.com/BCDA-APS/bcdaqwidgets/issues
version:2017.3.0
release:2.g80ebc1b.dirty
published:Apr 04, 2017

Overview

–tba–

Contents

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

Demonstrations: bcdaqwidgets_demos

pvview

display one or more EPICS PVs in a PyQt4 GUI window as a table

class bcdaqwidgets.pvview.PVView(parent=None)[source]
add(pvname)[source]

add a PV to the table

vlinac

provide a basic GUI for the APS EPICS Virtual Linac demo software

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

class bcdaqwidgets_demos.vlinac.DemoView(parent=None, prefix='unknown')[source]

simple entry and label widgets for the most important PVs

bcdaqwidgets_demos.vlinac.main()[source]

demonstrate use of this module

pyqt4_probe

PyQt4 implementation of EPICS probe

author:Matt Newville, CARS, University of Chicago
note:Does not use bcdaqwidgets
class bcdaqwidgets_demos.pyqt4_probe.PVProbe(parent=None)[source]

frame that monitors a user-entered EPICS PV

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

updates the widget (not thread-safe)

onPVNameReturn()[source]

responds when user enters a new PV

Dependencies

This software was built with various standard Python packages available in Python 2.7. Additionally, this program uses:

PyEpics (EPICS interface)
http://cars9.uchicago.edu/software/python/pyepics3/
PyQt4 (Qt4 widget library)
http://http://www.riverbankcomputing.com/software/pyqt/intro/

Changes

This describes user-visible changes between versions.

Production releases

2017.3.0:
  • inital public release

Unreleased (development) Versions

2015.0415.0:minor: convert QString to str
2015.0413.0:replaced PySide support with PyQt4 since PySide project is decaying
0.1.5:changed packaging to simplify building docs at readthedocs.org
0.1.4:revised PyQt import to pick what has already been imported
0.1.2:add BcdaQLabel_RBV widget for motors
0.1.1:handle color of alarm severity for CALC_INVALID
0.1:initial trial

License

Copyright (c) 2009-2017, UChicago Argonne, LLC

All Rights Reserved

BcdaQWidgets

BCDA, Advanced Photon Source, Argonne National Laboratory


OPEN SOURCE LICENSE

Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, 
   this list of conditions and the following disclaimer.  Software changes, 
   modifications, or derivative works, should be noted with comments and 
   the author and organization's name.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation 
   and/or other materials provided with the distribution.

3. Neither the names of UChicago Argonne, LLC or the Department of Energy 
   nor the names of its contributors may be used to endorse or promote 
   products derived from this software without specific prior written 
   permission.

4. The software and the end-user documentation included with the 
   redistribution, if any, must include the following acknowledgment:

   "This product includes software produced by UChicago Argonne, LLC 
   under Contract No. DE-AC02-06CH11357 with the Department of Energy."

****************************************************************************

DISCLAIMER

THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT WARRANTY OF ANY KIND.

Neither the United States GOVERNMENT, nor the United States Department 
of Energy, NOR uchicago argonne, LLC, nor any of their employees, makes 
any warranty, express or implied, or assumes any legal liability or 
responsibility for the accuracy, completeness, or usefulness of any 
information, data, apparatus, product, or process disclosed, or 
represents that its use would not infringe privately owned rights.

****************************************************************************

Indices and tables