External Data Plugins

To add an external data plugin to PyDM, you will need to subclass the following base class and customize its methods:

class pydm.data_plugins.PyDMPlugin[source]

Bases: object

connection_class

alias of pydm.data_plugins.plugin.PyDMConnection

You will also need to create a connection class and refer to it with the connection_class class variable. It should be subclassed from the following:

class pydm.data_plugins.plugin.PyDMConnection(channel, address, protocol=None, parent=None)[source]

Bases: PyQt5.QtCore.QObject

blockSignals(self, bool) bool
childEvent(self, QChildEvent)
children(self) object
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
deleteLater(self)
destroyed

destroyed(self, QObject = None) [signal]

disconnect(self)
disconnectNotify(self, QMetaMethod)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) object
event(self, QEvent) bool
eventFilter(self, QObject, QEvent) bool
findChild(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) QObject
findChild(self, Tuple, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) QObject
findChildren(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, Tuple, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, type, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, Tuple, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, type, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, Tuple, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
inherits(self, str) bool
installEventFilter(self, QObject)
isSignalConnected(self, QMetaMethod) bool
isWidgetType(self) bool
isWindowType(self) bool
killTimer(self, int)
metaObject(self) QMetaObject
moveToThread(self, QThread)
objectName(self) str
objectNameChanged

objectNameChanged(self, str) [signal]

parent(self) QObject
property(self, str) Any
pyqtConfigure(...)

Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.

receivers(self, PYQT_SIGNAL) int
removeEventFilter(self, QObject)
remove_listener(channel, destroying: Optional[bool] = False) None[source]

Removes a listener from this PyDMConnection. If there are no more listeners remaining after removal, then the PyDMConnection will be closed.

Parameters
  • channel (PyDMChannel) – The PyDMChannel containing the signals/slots that were being used to listen to the connected address.

  • destroying (bool, optional) – Should be set to True if this method is being invoked from a flow in which the PyDMWidget using this channel is being destroyed. Since Qt will automatically handle the disconnect of signals/slots when a QObject is destroyed, setting this to True ensures we do not try to do the disconnection a second time. If set to False, any active signals/slots on the channel will be manually disconnected here.

sender(self) QObject
senderSignalIndex(self) int
setObjectName(self, str)
setParent(self, QObject)
setProperty(self, str, Any) bool
signalsBlocked(self) bool
startTimer(self, int, timerType: Qt.TimerType = Qt.CoarseTimer) int
thread(self) QThread
timerEvent(self, QTimerEvent)
tr(self, str, disambiguation: str = None, n: int = - 1) str

Configuration

There are two options for telling PyDM where your external data plugin can be found.

The first is the PYDM_DATA_PLUGINS_PATH environment variable, which is an delimited list of paths to search for files that match the pattern *_plugin.py. They can be in the provided path or any subdirectory of that path. On Linux, the delimiter is “:” whereas on Windows it is “;”.

Alternatively, for Python packages that contain external data plugins, an entrypoint may be used to locate it.

Here is an example setup.py that could be used to locate a PyDM data plugin in your own Python package:

from setuptools import setup, find_packages

setup(
    name="my_package",
    # ... other settings will go here
    entry_points={
        "gui_scripts": ["my_package_gui=my_package.main:main"],
        "pydm.data_plugin": [
            "my_package=my_package.data:PluginClassName",
        ],
    },
    install_requires=[],
)

This would assume that you have the following:

  1. A package named “my_package” with my_package/__init__.py and my_package/data.py.

  2. In my_package/data.py, a PluginClassName that inherits from PyDMPlugin.

After running pip install on the package, it should be readily available in PyDM.