From cafa259ab46ab3703076980e80877f299bc22f23 Mon Sep 17 00:00:00 2001 From: vortexisalpha Date: Sun, 13 Jul 2025 19:34:46 +0100 Subject: [PATCH 1/2] added feature to all but image search window --- src/utils/gui.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/utils/gui.py b/src/utils/gui.py index deaf1fa..c7485cd 100644 --- a/src/utils/gui.py +++ b/src/utils/gui.py @@ -19,6 +19,7 @@ def __init__(self): self.minsize(950, 600) self.current_file = None self.is_dark_mode = False # Track dark mode state + self.browse_image_widgets = [] self.iris = None # Initialize IRIS attribute self._set_theme() # Apply the initial theme self._build_layout() @@ -133,6 +134,7 @@ def _add_text_tab(self, label, attr_name): frame = ttk.Frame(self.notebook) textbox = tk.Text(frame, wrap="word", bg=self.textbox_bg, relief="flat", font=("Consolas", 10), fg=self.textbox_fg) textbox.pack(fill="both", expand=True, padx=10, pady=10) + self._create_browse_image_widget(textbox) setattr(self, attr_name, textbox) self.notebook.add(frame, text=label) @@ -140,9 +142,24 @@ def _add_image_tab(self): frame = ttk.Frame(self.notebook) self.canvas = tk.Canvas(frame, background=self.textbox_bg, relief="flat") self.canvas.pack(fill="both", expand=True, padx=10, pady=10) + self._create_browse_image_widget(self.canvas, padding_x=10, padding_y=10) self.notebook.add(frame, text="Image View") + def _create_browse_image_widget(self, parent, padding_x: int = 0, padding_y: int = 0): + container = ttk.Frame(parent) + container.pack(fill="both", padx=padding_x, pady= padding_y) + ttk.Label(container, text="📁 Select Image", style="SubHeader.TLabel").pack(anchor="w", pady=(10, 5)) + ttk.Button(container, text="Browse...", command=self._browse_file).pack(fill="x") + self.lbl_file = ttk.Label(container, text="No file selected", wraplength=230) + self.lbl_file.pack(fill="x", pady=(5, 15)) + self.browse_image_widgets.append(container) + + def _browse_file(self): + # Delete browse image widgets + [container.pack_forget() for container in self.browse_image_widgets] + + # Open file selection path = filedialog.askopenfilename(filetypes=[("Images", "*.jpg *.jpeg *.png *.bmp *.gif *.webp *.tiff")]) if not path: return From 26ae7174bd7d0a746deedffaff9586c7376ca940 Mon Sep 17 00:00:00 2001 From: vortexisalpha Date: Sun, 13 Jul 2025 19:37:54 +0100 Subject: [PATCH 2/2] added image search tab preload browse image widget --- src/utils/gui.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/gui.py b/src/utils/gui.py index c7485cd..83a25d2 100644 --- a/src/utils/gui.py +++ b/src/utils/gui.py @@ -278,6 +278,7 @@ def _add_image_search_tab(self): textbox = tk.Text(frame, wrap="word", bg=self.textbox_bg, relief="flat", font=("Consolas", 10), fg=self.textbox_fg) textbox.pack(fill="both", expand=True, padx=10, pady=(0, 10)) + self._create_browse_image_widget(textbox) self.txt_search = textbox self.notebook.add(frame, text="Image Search")