From 2089f482ca4dfdff8d8b35232814c9966cb91539 Mon Sep 17 00:00:00 2001 From: kdmukai Date: Fri, 19 Jul 2024 17:12:36 -0500 Subject: [PATCH] Suggested cleanups --- src/seedsigner/gui/components.py | 5 ++--- src/seedsigner/gui/screens/psbt_screens.py | 11 +++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/seedsigner/gui/components.py b/src/seedsigner/gui/components.py index a086183c..9193e451 100644 --- a/src/seedsigner/gui/components.py +++ b/src/seedsigner/gui/components.py @@ -616,8 +616,7 @@ class FormattedAddress(BaseComponent): # Fixed width font means we only have to measure one max-height character left, top, right, bottom = self.font.getbbox("Q") - ascent, descent = self.font.getmetrics() - char_width, char_height = right - left, bottom - top + descent + char_width, char_height = right - left, bottom - top n = 7 display_str = f"{self.address[:n]} {self.address[n:-1*n]} {self.address[-1*n:]}" @@ -740,7 +739,7 @@ class FormattedAddress(BaseComponent): )) remaining_display_str = remaining_display_str[max_chars_per_line:] - cur_y += char_height + cur_y += char_height + GUIConstants.BODY_LINE_SPACING self.height = cur_y diff --git a/src/seedsigner/gui/screens/psbt_screens.py b/src/seedsigner/gui/screens/psbt_screens.py index 92211aaf..36a2b895 100644 --- a/src/seedsigner/gui/screens/psbt_screens.py +++ b/src/seedsigner/gui/screens/psbt_screens.py @@ -512,8 +512,7 @@ class PSBTMathScreen(ButtonListScreen): body_font = Fonts.get_font(GUIConstants.BODY_FONT_NAME, (GUIConstants.BODY_FONT_SIZE)*ssf) fixed_width_font = Fonts.get_font(GUIConstants.FIXED_WIDTH_FONT_NAME, (GUIConstants.BODY_FONT_SIZE + 6)*ssf) left, top, right, bottom = fixed_width_font.getbbox(self.input_amount + "Q") - ascent, descent = fixed_width_font.getmetrics() - digits_width, digits_height = right - left, bottom - top + descent + digits_width, digits_height = right - left, bottom - top # Draw each line of the equation cur_y = 0 @@ -551,7 +550,7 @@ class PSBTMathScreen(ButtonListScreen): # spend_amount will be zero on self-transfers; only display when there's an # external recipient. if self.num_recipients > 0: - cur_y += int(digits_height * 1.2) + cur_y += digits_height + GUIConstants.BODY_LINE_SPACING * ssf render_amount( cur_y, f"-{self.spend_amount}", @@ -559,16 +558,16 @@ class PSBTMathScreen(ButtonListScreen): info_text=f""" recipient{"s" if self.num_recipients > 1 else ""}""", ) - cur_y += int(digits_height * 1.2) + cur_y += digits_height + GUIConstants.BODY_LINE_SPACING * ssf render_amount( cur_y, f"-{self.fee_amount}", info_text=f""" fee""", ) - cur_y += int(digits_height * 1.2) + 4 * ssf + cur_y += digits_height + GUIConstants.BODY_LINE_SPACING * ssf draw.line((0, cur_y, image.width, cur_y), fill=GUIConstants.BODY_FONT_COLOR, width=1) - cur_y += 8 * ssf + cur_y += GUIConstants.BODY_LINE_SPACING * ssf render_amount( cur_y,