From 1ed00554db54680e2d83eaebc01f15e680fa2d47 Mon Sep 17 00:00:00 2001 From: "K1llM@n" Date: Sat, 3 Jun 2023 09:57:53 +0300 Subject: [PATCH] Auto adjust window size to preview --- roop/ui.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/roop/ui.py b/roop/ui.py index 69cf5ee..46cf9a2 100644 --- a/roop/ui.py +++ b/roop/ui.py @@ -5,22 +5,19 @@ from PIL import Image, ImageTk class PreviewWindow: def __init__(self, master): - self.preview_width = 600 - self.preview_height = 650 + self.max_preview_size = 800 self.master = master self.window = tk.Toplevel(self.master) # Override close button self.window.protocol("WM_DELETE_WINDOW", self.hide) self.window.withdraw() - self.window.geometry("600x700") self.window.title("Preview") self.window.configure(bg="red") self.window.resizable(width=False, height=False) self.visible = False self.frame = tk.Frame(self.window, background="#2d3436") - self.frame.pack_propagate(0) self.frame.pack(fill='both', side='left', expand='True') # Preview image @@ -73,9 +70,9 @@ class PreviewWindow: width, height = img.size aspect_ratio = 1 if width > height: - aspect_ratio = self.preview_width / width + aspect_ratio = self.max_preview_size / width else: - aspect_ratio = self.preview_height / height + aspect_ratio = self.max_preview_size / height img = img.resize( ( int(width * aspect_ratio),