Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def alarm_severity_changed(self, new_alarm_severity):
PyDMWidget.alarm_severity_changed(self, new_alarm_severity)
if new_alarm_severity == PyDMWidget.ALARM_NONE:
if self._original_brush is not None:
self.brush = self._original_brush
if self._original_pen_color is not None:
self.penColor = self._original_pen_color
if self._original_pen_style is not None:
self.penStyle = self._original_pen_style
from ..PyQt.QtGui import QFrame
from ..PyQt.QtCore import pyqtProperty
from .base import PyDMWidget
class PyDMFrame(QFrame, PyDMWidget):
"""
QFrame with support for alarms
This class inherits from QFrame and PyDMWidget.
Parameters
----------
parent : QWidget
The parent widget for the Label
init_channel : str, optional
The channel to be used by the widget.
"""
def __init__(self, parent=None, init_channel=None):
QFrame.__init__(self, parent)
PyDMWidget.__init__(self, init_channel=init_channel)
self._disable_on_disconnect = False
-------
bool
True to stop the event from being handled further; otherwise
return false.
"""
channel = getattr(self, 'channel', None)
if is_channel_valid(channel):
status = self._write_access and self._connected
if event.type() == QEvent.Leave:
QApplication.restoreOverrideCursor()
if event.type() == QEvent.Enter and not status:
QApplication.setOverrideCursor(QCursor(Qt.ForbiddenCursor))
return PyDMWidget.eventFilter(self, obj, event)
def set_scale_height(self, value):
self._scale_height = int(value)
self.adjust_transformation()
self.repaint()
def get_origin_at_zero(self):
return self._origin_at_zero
def set_origin_at_zero(self, checked):
if self._origin_at_zero != bool(checked):
self._origin_at_zero = checked
self.repaint()
class PyDMScaleIndicator(QFrame, TextFormatter, PyDMWidget):
"""
A bar-shaped indicator for scalar value with support for Channels and
more from PyDM.
Configurable features include indicator type (bar/pointer), scale tick
marks and orientation (horizontal/vertical).
Parameters
----------
parent : QWidget
The parent widget for the Scale
init_channel : str, optional
The channel to be used by the widget.
"""
def __init__(self, parent=None, init_channel=None):
QFrame.__init__(self, parent)
import json
import logging
from qtpy.QtWidgets import QApplication, QWidget, QStyle, QStyleOption
from qtpy.QtGui import QPainter, QPixmap
from qtpy.QtCore import Property, Qt, QSize, QSizeF, QRectF, qInstallMessageHandler
from qtpy.QtSvg import QSvgRenderer
from ..utilities import is_pydm_app
from .base import PyDMWidget
logger = logging.getLogger(__name__)
class PyDMSymbol(QWidget, PyDMWidget):
"""
PyDMSymbol will render an image (symbol) for each value of a channel.
Parameters
----------
parent : QWidget
The parent widget for the Label
init_channel : str, optional
The channel to be used by the widget.
"""
def __init__(self, parent=None, init_channel=None):
QWidget.__init__(self, parent)
PyDMWidget.__init__(self, init_channel=init_channel)
if 'Index' not in PyDMSymbol.RULE_PROPERTIES:
PyDMSymbol.RULE_PROPERTIES = PyDMWidget.RULE_PROPERTIES.copy()
PyDMSymbol.RULE_PROPERTIES.update(
def __init__(self, parent=None, init_channel=None):
QWidget.__init__(self, parent)
PyDMWidget.__init__(self, init_channel=init_channel)
if 'Index' not in PyDMSymbol.RULE_PROPERTIES:
PyDMSymbol.RULE_PROPERTIES = PyDMWidget.RULE_PROPERTIES.copy()
PyDMSymbol.RULE_PROPERTIES.update(
{'Index': ['set_current_key', object]})
self.app = QApplication.instance()
self._current_key = 0
self._state_images_string = ""
self._state_images = {} # Keyed on state values (ints), values are (filename, qpixmap or qsvgrenderer) tuples.
self._aspect_ratio_mode = Qt.KeepAspectRatio
self._sizeHint = self.minimumSizeHint()
self._painter = QPainter()
import numpy as np
from qtpy import QtWidgets
from .base import PyDMWidget
class PyDMTreeView(QtWidgets.QWidget, PyDMWidget):
def __init__(self, parent=None, init_channel=None):
QtWidgets.QWidget.__init__(self, parent)
PyDMWidget.__init__(self, init_channel)
self._items = {}
self.setLayout(QtWidgets.QVBoxLayout())
self.widget = QtWidgets.QTreeWidget(self)
self.widget.setHeaderLabels(['Key', 'Value'])
self.layout().addWidget(self.widget)
self._items['root'] = self.widget.invisibleRootItem()
self._visited_items = set(['root'])
def _create_node(self, parent, name, display, value, expanded=True):
if name not in self._items:
widget = QtWidgets.QTreeWidgetItem(self._items[parent])
widget.setText(0, display)
from .base import PyDMWidget, TextFormatter
from qtpy.QtWidgets import QLabel, QApplication
from qtpy.QtCore import Qt, Property, Q_ENUMS
from .display_format import DisplayFormat, parse_value_for_display
from pydm.utilities import is_pydm_app, is_qt_designer
from pydm import config
class PyDMLabel(QLabel, TextFormatter, PyDMWidget, DisplayFormat):
Q_ENUMS(DisplayFormat)
DisplayFormat = DisplayFormat
"""
A QLabel with support for setting the text via a PyDM Channel, or
through the PyDM Rules system.
Note: If a PyDMLabel is configured to use a Channel, and also with a rule
which changes the 'Text' property, the behavior is undefined. Use either
the Channel *or* a text rule, but not both.
Parameters
----------
parent : QWidget
The parent widget for the Label
init_channel : str, optional
The channel to be used by the widget.