Skip to content

Commit

Permalink
ran pre commits
Browse files Browse the repository at this point in the history
  • Loading branch information
phys-cgarnier committed Feb 14, 2024
1 parent 455d85a commit 7e3fc65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 32 deletions.
32 changes: 8 additions & 24 deletions pydm/widgets/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,11 @@ def get_inner_max(self):
origHeight = self.height()

if origWidth == 0:
logger.error(
"Invalid width. The value must be greater than {0}".format(origWidth)
)
logger.error("Invalid width. The value must be greater than {0}".format(origWidth))
return

if origHeight == 0:
logger.error(
"Invalid height. The value must be greater than {0}".format(origHeight)
)
logger.error("Invalid height. The value must be greater than {0}".format(origHeight))
return

if origWidth <= origHeight:
Expand Down Expand Up @@ -834,9 +830,7 @@ def draw_item(self, painter):
super(PyDMDrawingImage, self).draw_item(painter)
x, y, w, h = self.get_bounds(maxsize=True, force_no_pen=True)
if not isinstance(self._pixmap, QMovie):
_scaled = self._pixmap.scaled(
int(w), int(h), self._aspect_ratio_mode, Qt.SmoothTransformation
)
_scaled = self._pixmap.scaled(int(w), int(h), self._aspect_ratio_mode, Qt.SmoothTransformation)
# Make sure the image is centered if smaller than the widget itself
if w > _scaled.width():
logger.debug("Centering image horizontally ...")
Expand Down Expand Up @@ -1074,9 +1068,7 @@ def draw_item(self, painter):
super(PyDMDrawingArc, self).draw_item(painter)
maxsize = not self.is_square()
x, y, w, h = self.get_bounds(maxsize=maxsize)
painter.drawArc(
QRectF(x, y, w, h), int(self._start_angle), int(self._span_angle)
)
painter.drawArc(QRectF(x, y, w, h), int(self._start_angle), int(self._span_angle))


class PyDMDrawingPie(PyDMDrawingArc):
Expand All @@ -1103,9 +1095,7 @@ def draw_item(self, painter):
super(PyDMDrawingPie, self).draw_item(painter)
maxsize = not self.is_square()
x, y, w, h = self.get_bounds(maxsize=maxsize)
painter.drawPie(
QRectF(x, y, w, h), int(self._start_angle), int(self._span_angle)
)
painter.drawPie(QRectF(x, y, w, h), int(self._start_angle), int(self._span_angle))


class PyDMDrawingChord(PyDMDrawingArc):
Expand All @@ -1132,9 +1122,7 @@ def draw_item(self, painter):
super(PyDMDrawingChord, self).draw_item(painter)
maxsize = not self.is_square()
x, y, w, h = self.get_bounds(maxsize=maxsize)
painter.drawChord(
QRectF(x, y, w, h), int(self._start_angle), int(self._span_angle)
)
painter.drawChord(QRectF(x, y, w, h), int(self._start_angle), int(self._span_angle))


class PyDMDrawingPolygon(PyDMDrawing):
Expand Down Expand Up @@ -1253,16 +1241,12 @@ def p2d(pt):
midpoint_x = (point1.x() + point2.x()) / 2
midpoint_y = (point1.y() + point2.y()) / 2
midpoint = QPointF(midpoint_x, midpoint_y)
points = PyDMDrawingLine._arrow_points(
point1, midpoint, 6, 6
) # 6 = arbitrary arrow size
points = PyDMDrawingLine._arrow_points(point1, midpoint, 6, 6) # 6 = arbitrary arrow size
painter.drawPolygon(points)

# Draw the arrows
if self._arrow_end_point_selection and (len(self._points[1]) >= 2):
points = PyDMDrawingLine._arrow_points(
p2d(self._points[1]), p2d(self._points[0]), 6, 6
)
points = PyDMDrawingLine._arrow_points(p2d(self._points[1]), p2d(self._points[0]), 6, 6)
painter.drawPolygon(points)

if self._arrow_start_point_selection and (len(self._points[1]) >= 2):
Expand Down
11 changes: 3 additions & 8 deletions pydm/widgets/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,8 @@ def register(self, widget, rules):

for ch_idx, ch in enumerate(channels_list):
conn_cb = functools.partial(self.callback_conn, widget_ref, idx, ch_idx)
value_cb = functools.partial(
self.callback_value, widget_ref, idx, ch_idx, ch["trigger"]
)
enums_cb = functools.partial(
self.callback_enum, widget_ref, idx, ch_idx
)
value_cb = functools.partial(self.callback_value, widget_ref, idx, ch_idx, ch["trigger"])
enums_cb = functools.partial(self.callback_enum, widget_ref, idx, ch_idx)
c = PyDMChannel(
ch["channel"],
connection_slot=conn_cb,
Expand Down Expand Up @@ -376,8 +372,7 @@ def calculate_expression(self, widget_ref, idx, rule):
self.emit_value(widget_ref, name, prop, val)
except Exception:
logger.exception(
f"Error while evaluating Rule with name: {name} and type: {prop} "
f"and expression: {expression}"
f"Error while evaluating Rule with name: {name} and type: {prop} " f"and expression: {expression}"
)

def emit_value(self, widget_ref, name, prop, val):
Expand Down

0 comments on commit 7e3fc65

Please sign in to comment.