Skip to content

Commit

Permalink
Merge pull request #1066 from phys-cgarnier/master
Browse files Browse the repository at this point in the history
ENH: added new pydm drawing rules for all drawing widgets that allow for p…
  • Loading branch information
YektaY authored Apr 15, 2024
2 parents 56f94b4 + 261af4f commit ec62b26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pydm/widgets/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"Set Pen Color": ["penColor", QColor],
"Set Pen Style": ["penStyle", int],
"Set Pen Width": ["penWidth", float],
"Set Brush Color": ["brush", QBrush],
}


Expand Down Expand Up @@ -57,7 +58,7 @@ def qt_to_deg(deg):
return deg / 16.0


class PyDMDrawing(QWidget, PyDMWidget):
class PyDMDrawing(QWidget, PyDMWidget, new_properties=_penRuleProperties):
"""
Base class to be used for all PyDM Drawing Widgets.
This class inherits from QWidget and PyDMWidget.
Expand Down Expand Up @@ -453,7 +454,7 @@ def alarm_severity_changed(self, new_alarm_severity):
self.penStyle = self._original_pen_style


class PyDMDrawingLine(PyDMDrawing, new_properties=_penRuleProperties):
class PyDMDrawingLine(PyDMDrawing):
"""
A widget with a line drawn in it.
This class inherits from PyDMDrawing.
Expand Down
4 changes: 2 additions & 2 deletions pydm/widgets/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from qtpy.QtCore import QThread, QMutex, Signal
from qtpy.QtWidgets import QWidget, QApplication
from qtpy.QtGui import QColor
from qtpy.QtGui import QColor, QBrush
from ..utilities import is_qt_designer
from .channel import PyDMChannel

Expand Down Expand Up @@ -361,7 +361,7 @@ def calculate_expression(self, widget_ref, idx, rule):
pass
calc_vals.append(v)

eval_env = {"np": np, "ch": calc_vals, "QColor": QColor}
eval_env = {"np": np, "ch": calc_vals, "QColor": QColor, "QBrush": QBrush}
eval_env.update({k: v for k, v in math.__dict__.items() if k[0] != "_"})

expression = rule["rule"]["expression"]
Expand Down

0 comments on commit ec62b26

Please sign in to comment.