From 47877dc245a10db33b38cb74552698326f857c48 Mon Sep 17 00:00:00 2001 From: Robin David Date: Sat, 8 Oct 2022 17:15:48 +0200 Subject: [PATCH] convert float to int as expected by Qt API functions --- plugins/tenet/ui/reg_view.py | 6 +++--- plugins/tenet/util/qt/util.py | 10 +++++----- plugins/tenet/util/qt/waitbox.py | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/tenet/ui/reg_view.py b/plugins/tenet/ui/reg_view.py index 6f5ce2d..5383d30 100644 --- a/plugins/tenet/ui/reg_view.py +++ b/plugins/tenet/ui/reg_view.py @@ -163,7 +163,7 @@ def _init_reg_positions(self): y += self._char_height name_rect = QtCore.QRect(0, 0, name_size.width(), name_size.height()) - name_rect.moveBottomLeft(QtCore.QPoint(name_x, y)) + name_rect.moveBottomLeft(QtCore.QPoint(int(name_x), int(y))) prev_rect = QtCore.QRect(0, 0, arrow_size, arrow_size) next_rect = QtCore.QRect(0, 0, arrow_size, arrow_size) @@ -175,7 +175,7 @@ def _init_reg_positions(self): value_x = prev_x + prev_rect.width() + self._char_width value_rect = QtCore.QRect(0, 0, value_size.width(), value_size.height()) - value_rect.moveBottomLeft(QtCore.QPoint(value_x, y)) + value_rect.moveBottomLeft(QtCore.QPoint(int(value_x), int(y))) next_x = value_x + value_size.width() + self._char_width next_rect.moveCenter(name_rect.center()) @@ -542,4 +542,4 @@ def __init__(self, name, name_rect, value_rect, arrow_rects): self.name_rect = name_rect self.value_rect = value_rect self.prev_rect = arrow_rects[0] - self.next_rect = arrow_rects[1] \ No newline at end of file + self.next_rect = arrow_rects[1] diff --git a/plugins/tenet/util/qt/util.py b/plugins/tenet/util/qt/util.py index 758f41a..ccf745b 100644 --- a/plugins/tenet/util/qt/util.py +++ b/plugins/tenet/util/qt/util.py @@ -53,7 +53,7 @@ def get_dpi_scale(): fm = QtGui.QFontMetricsF(font) # xHeight is expected to be 40.0 at normal DPI - return fm.height() / 173.0 + return int(fm.height() / 173.0) def normalize_font(font_size): """ @@ -78,9 +78,9 @@ def compute_color_on_gradient(percent, color1, color2): r2, g2, b2, _ = color2.getRgb() # compute the new color across the gradient of color1 -> color 2 - r = r1 + percent * (r2 - r1) - g = g1 + percent * (g2 - g1) - b = b1 + percent * (b2 - b1) + r = r1 + int(percent * (r2 - r1)) + g = g1 + int(percent * (g2 - g1)) + b = b1 + int(percent * (b2 - b1)) # return the new color - return QtGui.QColor(r,g,b) \ No newline at end of file + return QtGui.QColor(r,g,b) diff --git a/plugins/tenet/util/qt/waitbox.py b/plugins/tenet/util/qt/waitbox.py index c0b05f9..5e55dd8 100644 --- a/plugins/tenet/util/qt/waitbox.py +++ b/plugins/tenet/util/qt/waitbox.py @@ -62,7 +62,7 @@ def _ui_init(self): # configure the main widget / form self.setSizeGripEnabled(False) self.setModal(True) - self._dpi_scale = get_dpi_scale()*5.0 + self._dpi_scale = get_dpi_scale()*5 # initialize abort button self._abort_button = QtWidgets.QPushButton("Cancel") @@ -99,4 +99,4 @@ def _ui_layout(self): self.setMinimumHeight(height) # compute the dialog layout - self.setLayout(v_layout) \ No newline at end of file + self.setLayout(v_layout)