Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: added new pydm drawing rules for all drawing widgets that allow for p… #1066

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading