From bea7d47d6825094a12201cec2464b13ae61ccc4c Mon Sep 17 00:00:00 2001 From: Billy Date: Sat, 15 Jul 2023 15:48:02 +0800 Subject: [PATCH] fix: Restrict resizing with minimum width/height --- biscuit/app.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/biscuit/app.py b/biscuit/app.py index f768b2c5..90dd5ac5 100644 --- a/biscuit/app.py +++ b/biscuit/app.py @@ -109,6 +109,9 @@ def setup_tk(self): self.scale = self.dpi_value / 72 self.tk.call('tk', 'scaling', self.scale) + self.min_width = round(500 * self.scale) + self.min_height = round(500 * self.scale) + app_width = round(1000 * self.scale) app_height = round(650 * self.scale) x = int((self.winfo_screenwidth() - app_width) / 2) @@ -269,19 +272,19 @@ def resize(self, mode): match mode: case 'e': - if height > 0 and abs_x > 0: + if height > self.min_height and abs_x > self.min_width: return self.geometry(f"{abs_x}x{height}") case 'n': height = height - abs_y y = y + abs_y - if height > 0 and width > 0: + if height > self.min_height and width > self.min_width: return self.geometry(f"{width}x{height}+{x}+{y}") case 'w': width = width - abs_x x = x + abs_x - if height > 0 and width > 0: + if height > self.min_height and width > self.min_width: return self.geometry(f"{width}x{height}+{x}+{y}") case 's': height = height - (height - abs_y) - if height > 0 and width > 0: + if height > self.min_height and width > self.min_width: return self.geometry(f"{width}x{height}+{x}+{y}")