diff --git a/pydm/tests/widgets/test_timeplot.py b/pydm/tests/widgets/test_timeplot.py index 737a8a842..f0f097b88 100644 --- a/pydm/tests/widgets/test_timeplot.py +++ b/pydm/tests/widgets/test_timeplot.py @@ -117,7 +117,7 @@ def test_timeplotcurveitem_receive_value(qtbot, signals, async_update, new_data) pydm_timeplot_curve_item.setUpdatesAsynchronously(async_update) if async_update: assert ( - pydm_timeplot_curve_item._update_mode == PyDMTimePlot.AtFixedRated + pydm_timeplot_curve_item._update_mode == PyDMTimePlot.AtFixedRate if async_update else pydm_timeplot_curve_item._update_mode == PyDMTimePlot.OnValueChange ) diff --git a/pydm/widgets/datetime.py b/pydm/widgets/datetime.py index fdc52af14..5b73249a4 100644 --- a/pydm/widgets/datetime.py +++ b/pydm/widgets/datetime.py @@ -11,8 +11,13 @@ class TimeBase(object): Seconds = 1 -class PyDMDateTimeEdit(QtWidgets.QDateTimeEdit, PyDMWritableWidget, TimeBase): +class PyDMDateTimeEdit(QtWidgets.QDateTimeEdit, PyDMWritableWidget): QtCore.Q_ENUMS(TimeBase) + + # Make enum definitions known to this class + Milliseconds = TimeBase.Milliseconds + Seconds = TimeBase.Seconds + returnPressed = QtCore.Signal() """ A QDateTimeEdit with support for setting the text via a PyDM Channel, or @@ -107,8 +112,13 @@ def value_changed(self, new_val): self.setDateTime(val) -class PyDMDateTimeLabel(QtWidgets.QLabel, PyDMWidget, TimeBase): +class PyDMDateTimeLabel(QtWidgets.QLabel, PyDMWidget): QtCore.Q_ENUMS(TimeBase) + + # Make enum definitions known to this class + Milliseconds = TimeBase.Milliseconds + Seconds = TimeBase.Seconds + """ A QLabel with support for setting the text via a PyDM Channel, or through the PyDM Rules system. diff --git a/pydm/widgets/display_format.py b/pydm/widgets/display_format.py index c3a2da569..763b2db9f 100644 --- a/pydm/widgets/display_format.py +++ b/pydm/widgets/display_format.py @@ -1,7 +1,6 @@ import math import numpy as np from typing import Any - import logging import warnings diff --git a/pydm/widgets/enum_button.py b/pydm/widgets/enum_button.py index ef806cf3c..273f45d28 100644 --- a/pydm/widgets/enum_button.py +++ b/pydm/widgets/enum_button.py @@ -18,7 +18,7 @@ class WidgetType(object): logger = logging.getLogger(__name__) -class PyDMEnumButton(QWidget, PyDMWritableWidget, WidgetType): +class PyDMEnumButton(QWidget, PyDMWritableWidget): """ A QWidget that renders buttons for every option of Enum Items. For now, two types of buttons can be rendered: @@ -41,6 +41,10 @@ class PyDMEnumButton(QWidget, PyDMWritableWidget, WidgetType): Q_ENUMS(WidgetType) WidgetType = WidgetType + # Make enum definitions known to this class + PushButton = WidgetType.PushButton + RadioButton = WidgetType.RadioButton + def __init__(self, parent=None, init_channel=None): QWidget.__init__(self, parent) PyDMWritableWidget.__init__(self, init_channel=init_channel) diff --git a/pydm/widgets/image.py b/pydm/widgets/image.py index 03b64038b..4aff949ad 100644 --- a/pydm/widgets/image.py +++ b/pydm/widgets/image.py @@ -98,7 +98,7 @@ def run(self): self.image_view.needs_redraw = False -class PyDMImageView(ImageView, PyDMWidget, PyDMColorMap, ReadingOrder, DimensionOrder): +class PyDMImageView(ImageView, PyDMWidget): """ A PyQtGraph ImageView with support for Channels and more from PyDM. @@ -130,6 +130,21 @@ class PyDMImageView(ImageView, PyDMWidget, PyDMColorMap, ReadingOrder, Dimension Q_ENUMS(DimensionOrder) Q_ENUMS(PyDMColorMap) + # Make enum definitions known to this class + Fortranlike = ReadingOrder.Fortranlike + Clike = ReadingOrder.Clike + + HeightFirst = DimensionOrder.HeightFirst + WidthFirst = DimensionOrder.WidthFirst + + Magma = PyDMColorMap.Magma + Inferno = PyDMColorMap.Inferno + Plasma = PyDMColorMap.Plasma + Viridis = PyDMColorMap.Viridis + Jet = PyDMColorMap.Jet + Monochrome = PyDMColorMap.Monochrome + Hot = PyDMColorMap.Hot + color_maps = cmaps def __init__(self, parent=None, image_channel=None, width_channel=None): diff --git a/pydm/widgets/label.py b/pydm/widgets/label.py index 787018a70..19605b397 100644 --- a/pydm/widgets/label.py +++ b/pydm/widgets/label.py @@ -9,7 +9,7 @@ _labelRuleProperties = {"Text": ["value_changed", str]} -class PyDMLabel(QLabel, TextFormatter, PyDMWidget, DisplayFormat, new_properties=_labelRuleProperties): +class PyDMLabel(QLabel, TextFormatter, PyDMWidget, new_properties=_labelRuleProperties): """ A QLabel with support for setting the text via a PyDM Channel, or through the PyDM Rules system. @@ -27,6 +27,13 @@ class PyDMLabel(QLabel, TextFormatter, PyDMWidget, DisplayFormat, new_properties The channel to be used by the widget. """ + Default = DisplayFormat.Default + String = DisplayFormat.String + Decimal = DisplayFormat.Decimal + Exponential = DisplayFormat.Exponential + Hex = DisplayFormat.Hex + Binary = DisplayFormat.Binary + Q_ENUMS(DisplayFormat) DisplayFormat = DisplayFormat diff --git a/pydm/widgets/line_edit.py b/pydm/widgets/line_edit.py index 545e5c225..12aca8271 100755 --- a/pydm/widgets/line_edit.py +++ b/pydm/widgets/line_edit.py @@ -14,7 +14,7 @@ logger = logging.getLogger(__name__) -class PyDMLineEdit(QLineEdit, TextFormatter, PyDMWritableWidget, DisplayFormat): +class PyDMLineEdit(QLineEdit, TextFormatter, PyDMWritableWidget): """ A QLineEdit (writable text field) with support for Channels and more from PyDM. @@ -32,6 +32,14 @@ class PyDMLineEdit(QLineEdit, TextFormatter, PyDMWritableWidget, DisplayFormat): Q_ENUMS(DisplayFormat) DisplayFormat = DisplayFormat + # Make enum definitions known to this class + Default = DisplayFormat.Default + String = DisplayFormat.String + Decimal = DisplayFormat.Decimal + Exponential = DisplayFormat.Exponential + Hex = DisplayFormat.Hex + Binary = DisplayFormat.Binary + def __init__(self, parent=None, init_channel=None): QLineEdit.__init__(self, parent) PyDMWritableWidget.__init__(self, init_channel=init_channel) diff --git a/pydm/widgets/logdisplay.py b/pydm/widgets/logdisplay.py index ec879c4be..71e4deb95 100644 --- a/pydm/widgets/logdisplay.py +++ b/pydm/widgets/logdisplay.py @@ -108,7 +108,7 @@ def as_dict(): return OrderedDict(sorted(entries, key=lambda x: x[1], reverse=False)) -class PyDMLogDisplay(QWidget, LogLevels): +class PyDMLogDisplay(QWidget): """ Standard display for Log Output @@ -131,6 +131,15 @@ class PyDMLogDisplay(QWidget, LogLevels): Q_ENUMS(LogLevels) LogLevels = LogLevels + + # Make enum definitions known to this class + NOTSET = LogLevels.NOTSET + DEBUG = LogLevels.DEBUG + INFO = LogLevels.INFO + WARNING = LogLevels.WARNING + ERROR = LogLevels.ERROR + CRITICAL = LogLevels.CRITICAL + terminator = "\n" default_format = "%(asctime)s %(message)s" default_level = logging.INFO diff --git a/pydm/widgets/template_repeater.py b/pydm/widgets/template_repeater.py index fbb2ef805..66e81d5a8 100644 --- a/pydm/widgets/template_repeater.py +++ b/pydm/widgets/template_repeater.py @@ -120,7 +120,7 @@ class LayoutType(object): layout_class_for_type = (QVBoxLayout, QHBoxLayout, FlowLayout) -class PyDMTemplateRepeater(QFrame, PyDMPrimitiveWidget, LayoutType): +class PyDMTemplateRepeater(QFrame, PyDMPrimitiveWidget): """ PyDMTemplateRepeater takes a .ui file with macro variables as a template, and a JSON file (or a list of dictionaries) with a list of values to use to fill in @@ -143,6 +143,11 @@ class PyDMTemplateRepeater(QFrame, PyDMPrimitiveWidget, LayoutType): Q_ENUMS(LayoutType) LayoutType = LayoutType + # Make enum definitions known to this class + Vertical = LayoutType.Vertical + Horizontal = LayoutType.Horizontal + Flow = LayoutType.Flow + def __init__(self, parent=None): pydm.data_plugins.initialize_plugins_if_needed() QFrame.__init__(self, parent) diff --git a/pydm/widgets/timeplot.py b/pydm/widgets/timeplot.py index 25d76ed41..c31f29e49 100644 --- a/pydm/widgets/timeplot.py +++ b/pydm/widgets/timeplot.py @@ -224,7 +224,7 @@ def receiveNewValue(self, new_value): if self.points_accumulated < self._bufferSize: self.points_accumulated += 1 self.data_changed.emit() - elif self._update_mode == PyDMTimePlot.AtFixedRated: + elif self._update_mode == PyDMTimePlot.AtFixedRate: self.latest_value = new_value @Slot() @@ -234,7 +234,7 @@ def asyncUpdate(self): buffer, together with the timestamp when this happens. Also increments the accumulated point counter. """ - if self._update_mode != PyDMTimePlot.AtFixedRated: + if self._update_mode != PyDMTimePlot.AtFixedRate: return self.data_buffer = np.roll(self.data_buffer, -1) self.data_buffer[0, self._bufferSize - 1] = time.time() @@ -412,7 +412,7 @@ def channels(self): return [self.channel] -class PyDMTimePlot(BasePlot, updateMode): +class PyDMTimePlot(BasePlot): """ PyDMTimePlot is a widget to plot one or more channels vs. time. @@ -437,12 +437,13 @@ class PyDMTimePlot(BasePlot, updateMode): to either a TimeAxisItem if plot_by_timestamps is true, or a regular AxisItem otherwise """ - OnValueChange = 1 - AtFixedRated = 2 - Q_ENUMS(updateMode) updateMode = updateMode + # Make enum definitions known to this class + OnValueChange = updateMode.OnValueChange + AtFixedRate = updateMode.AtFixedRate + plot_redrawn_signal = Signal(TimePlotCurveItem) def __init__( @@ -918,7 +919,7 @@ def resetBufferSize(self): bufferSize = Property("int", getBufferSize, setBufferSize, resetBufferSize) def getUpdatesAsynchronously(self): - return self._update_mode == PyDMTimePlot.AtFixedRated + return self._update_mode == PyDMTimePlot.AtFixedRate def setUpdatesAsynchronously(self, value): for curve in self._curves: