Skip to content

Commit

Permalink
fix: Restrict resizing with minimum width/height
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlin7 committed Jul 15, 2023
1 parent 3821e29 commit bea7d47
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions biscuit/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}")

0 comments on commit bea7d47

Please sign in to comment.