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

FIX: in analong_indicator, explicitly cast to int for py310+ compat #1080

Merged
merged 1 commit into from
May 30, 2024
Merged
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
36 changes: 28 additions & 8 deletions pydm/widgets/analog_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ def draw_indicator(self):
pointer_width = self._pointer_width_rate * self._widget_width
pointer_height = self._bg_size_rate * self._scale_height * 1.5
points = [
QPoint(self.position + 0.5 * pointer_width, 0),
QPoint(self.position - 0.5 * pointer_width, 0),
QPoint(self.position, pointer_height),
QPoint(int(self.position + 0.5 * pointer_width), 0),
QPoint(int(self.position - 0.5 * pointer_width), 0),
QPoint(int(self.position), int(pointer_height)),
]
self._painter.drawPolygon(QPolygon(points))

Expand All @@ -152,7 +152,7 @@ def draw_background(self):
pointer_height = self._bg_size_rate * self._scale_height
bg_width = self._widget_width
bg_height = self._bg_size_rate * self._widget_height - 2
self._painter.drawRect(0, pointer_height, bg_width, bg_height)
self._painter.drawRect(0, int(pointer_height), int(bg_width), int(bg_height))

def draw_minor_alarm_region(self):
"""
Expand All @@ -176,7 +176,12 @@ def draw_minor_alarm_region(self):
else:
self._painter.setBrush(self._minor_alarm_region_color)
if self._lower_minor_alarm > self._lower_limit:
self._painter.drawRect(0, pointer_height, lower_minor_alarm_width, minor_alarm_height)
self._painter.drawRect(
0,
int(pointer_height),
int(lower_minor_alarm_width),
int(minor_alarm_height),
)
"""
sets the pen color to alarm if the value is in the upper minor alarm region
"""
Expand All @@ -185,7 +190,12 @@ def draw_minor_alarm_region(self):
else:
self._painter.setBrush(self._minor_alarm_region_color)
if self._upper_minor_alarm < self._upper_limit:
self._painter.drawRect(upper_minor_alarm_start, pointer_height, upper_minor_alarm_width, minor_alarm_height)
self._painter.drawRect(
int(upper_minor_alarm_start),
int(pointer_height),
int(upper_minor_alarm_width),
int(minor_alarm_height),
)

def draw_major_alarm_region(self):
"""
Expand All @@ -211,7 +221,12 @@ def draw_major_alarm_region(self):
self._painter.setBrush(self._major_alarm_region_color)
# makes sure alarm value is in range
if self._lower_major_alarm > self._lower_limit:
self._painter.drawRect(0, pointer_height, lower_major_alarm_width, major_alarm_height)
self._painter.drawRect(
0,
int(pointer_height),
int(lower_major_alarm_width),
int(major_alarm_height),
)

"""
sets the pen color to alarm if the value is in the upper major alarm region
Expand All @@ -222,7 +237,12 @@ def draw_major_alarm_region(self):
self._painter.setBrush(self._major_alarm_region_color)
# makes sure alarm value is in range
if self._upper_major_alarm < self._upper_limit:
self._painter.drawRect(upper_major_alarm_start, pointer_height, upper_major_alarm_width, major_alarm_height)
self._painter.drawRect(
int(upper_major_alarm_start),
int(pointer_height),
int(upper_major_alarm_width),
int(major_alarm_height),
)

def paintEvent(self, event):
"""
Expand Down
Loading