Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3877 from pypeclub/bugfix/OP-3898_Publisher-NiceC…
Browse files Browse the repository at this point in the history
…heckbox-doenst-work-on-Creator-Attributes-in-Python-2-host

Publisher: Nice checkbox visible in Python 2
  • Loading branch information
iLLiCiTiT authored Sep 21, 2022
2 parents 8e84a96 + 3161d3d commit ee3ec64
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions openpype/widgets/nice_checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ def sizeHint(self):
return QtCore.QSize(width, height)

def get_width_hint_by_height(self, height):
return (
height / self._base_size.height()
) * self._base_size.width()
return int((
float(height) / self._base_size.height()
) * self._base_size.width())

def get_height_hint_by_width(self, width):
return (
width / self._base_size.width()
) * self._base_size.height()
return int((
float(width) / self._base_size.width()
) * self._base_size.height())

def setFixedHeight(self, *args, **kwargs):
self._fixed_height_set = True
Expand Down Expand Up @@ -321,7 +321,7 @@ def paintEvent(self, event):
bg_color = self.unchecked_bg_color

else:
offset_ratio = self._current_step / self._steps
offset_ratio = float(self._current_step) / self._steps
# Animation bg
bg_color = self.steped_color(
self.checked_bg_color,
Expand All @@ -332,7 +332,8 @@ def paintEvent(self, event):
margins_ratio = self._checker_margins_divider
if margins_ratio > 0:
size_without_margins = int(
(frame_rect.height() / margins_ratio) * (margins_ratio - 2)
(float(frame_rect.height()) / margins_ratio)
* (margins_ratio - 2)
)
size_without_margins -= size_without_margins % 2
margin_size_c = ceil(
Expand Down Expand Up @@ -434,21 +435,21 @@ def _get_middle_circle_path(self, painter, checker_rect):
def _get_enabled_icon_path(
self, painter, checker_rect, step=None, half_steps=None
):
fifteenth = checker_rect.height() / 15
fifteenth = float(checker_rect.height()) / 15
# Left point
p1 = QtCore.QPoint(
checker_rect.x() + (5 * fifteenth),
checker_rect.y() + (9 * fifteenth)
int(checker_rect.x() + (5 * fifteenth)),
int(checker_rect.y() + (9 * fifteenth))
)
# Middle bottom point
p2 = QtCore.QPoint(
checker_rect.center().x(),
checker_rect.y() + (11 * fifteenth)
int(checker_rect.y() + (11 * fifteenth))
)
# Top right point
p3 = QtCore.QPoint(
checker_rect.x() + (10 * fifteenth),
checker_rect.y() + (5 * fifteenth)
int(checker_rect.x() + (10 * fifteenth)),
int(checker_rect.y() + (5 * fifteenth))
)
if step is not None:
multiplier = (half_steps - step)
Expand All @@ -458,16 +459,16 @@ def _get_enabled_icon_path(
p3c = p3 - checker_rect.center()

p1o = QtCore.QPoint(
(p1c.x() / half_steps) * multiplier,
(p1c.y() / half_steps) * multiplier
int((float(p1c.x()) / half_steps) * multiplier),
int((float(p1c.y()) / half_steps) * multiplier)
)
p2o = QtCore.QPoint(
(p2c.x() / half_steps) * multiplier,
(p2c.y() / half_steps) * multiplier
int((float(p2c.x()) / half_steps) * multiplier),
int((float(p2c.y()) / half_steps) * multiplier)
)
p3o = QtCore.QPoint(
(p3c.x() / half_steps) * multiplier,
(p3c.y() / half_steps) * multiplier
int((float(p3c.x()) / half_steps) * multiplier),
int((float(p3c.y()) / half_steps) * multiplier)
)

p1 -= p1o
Expand All @@ -484,11 +485,12 @@ def _get_disabled_icon_path(
self, painter, checker_rect, step=None, half_steps=None
):
center_point = QtCore.QPointF(
checker_rect.width() / 2, checker_rect.height() / 2
float(checker_rect.width()) / 2,
float(checker_rect.height()) / 2
)
offset = (
offset = float((
(center_point + QtCore.QPointF(0, 0)) / 2
).x() / 4 * 5
).x()) / 4 * 5
if step is not None:
diff = center_point.x() - offset
diff_offset = (diff / half_steps) * (half_steps - step)
Expand Down

0 comments on commit ee3ec64

Please sign in to comment.