From 0fb6a19624858bb109bfa15ab37274a8f863910b Mon Sep 17 00:00:00 2001 From: tanyar09 Date: Tue, 30 Sep 2025 13:24:58 -0400 Subject: [PATCH] Refactor PhotoTagger GUI to improve search functionality. Update search controls for last name filtering by introducing a helper label and reorganizing layout for better usability. Adjust grid placements for matched person info and image to enhance visual clarity and consistency across the interface. --- photo_tagger.py | 66 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/photo_tagger.py b/photo_tagger.py index 63d3560..a44af24 100644 --- a/photo_tagger.py +++ b/photo_tagger.py @@ -3323,8 +3323,8 @@ class PhotoTagger: main_frame.columnconfigure(0, weight=1) main_frame.columnconfigure(1, weight=1) - # Left side - matched face (person) - left_frame = ttk.LabelFrame(main_frame, text="Matched Person", padding="10") + # Left side - identified person + left_frame = ttk.LabelFrame(main_frame, text="Identified person", padding="10") left_frame.grid(row=0, column=0, sticky=(tk.W, tk.E, tk.N, tk.S), padx=(0, 5)) # Right side - unidentified faces that match this person @@ -3336,22 +3336,34 @@ class PhotoTagger: # Search controls for filtering people by last name last_name_search_var = tk.StringVar() - search_row = ttk.Frame(left_frame) - search_row.grid(row=0, column=0, sticky=(tk.W, tk.E), pady=(0, 10)) - search_entry = ttk.Entry(search_row, textvariable=last_name_search_var, width=20) - search_entry.pack(side=tk.LEFT) - search_btn = ttk.Button(search_row, text="Search", width=8) - search_btn.pack(side=tk.LEFT, padx=(6, 0)) - clear_btn = ttk.Button(search_row, text="Clear", width=6) - clear_btn.pack(side=tk.LEFT, padx=(6, 0)) + # Search field with label underneath (like modifyidentified edit section) + search_frame = ttk.Frame(left_frame) + search_frame.grid(row=0, column=0, sticky=(tk.W, tk.E), pady=(0, 10)) + + # Search input on the left + search_entry = ttk.Entry(search_frame, textvariable=last_name_search_var, width=20) + search_entry.grid(row=0, column=0, sticky=tk.W) + + # Buttons on the right of the search input + buttons_row = ttk.Frame(search_frame) + buttons_row.grid(row=0, column=1, sticky=tk.W, padx=(6, 0)) + + search_btn = ttk.Button(buttons_row, text="Search", width=8) + search_btn.pack(side=tk.LEFT, padx=(0, 5)) + clear_btn = ttk.Button(buttons_row, text="Clear", width=6) + clear_btn.pack(side=tk.LEFT) + + # Helper label directly under the search input + last_name_label = ttk.Label(search_frame, text="Type Last Name", font=("Arial", 8), foreground="gray") + last_name_label.grid(row=1, column=0, sticky=tk.W, pady=(2, 0)) # Matched person info matched_info_label = ttk.Label(left_frame, text="", font=("Arial", 10, "bold")) - matched_info_label.grid(row=1, column=0, pady=(0, 10), sticky=tk.W) + matched_info_label.grid(row=2, column=0, pady=(0, 10), sticky=tk.W) # Matched person image matched_canvas = tk.Canvas(left_frame, width=300, height=300, bg='white') - matched_canvas.grid(row=2, column=0, pady=(0, 10)) + matched_canvas.grid(row=3, column=0, pady=(0, 10)) # Save button for this person (will be created after function definitions) save_btn = None @@ -3664,7 +3676,7 @@ class PhotoTagger: # Create save button now that functions are defined save_btn = ttk.Button(left_frame, text="💾 Save Changes", command=on_confirm_matches) - save_btn.grid(row=3, column=0, pady=(0, 10), sticky=(tk.W, tk.E)) + save_btn.grid(row=4, column=0, pady=(0, 10), sticky=(tk.W, tk.E)) def update_button_states(): """Update button states based on current position""" @@ -4030,16 +4042,26 @@ class PhotoTagger: people_frame.grid(row=1, column=0, sticky=(tk.W, tk.E, tk.N, tk.S), padx=(0, 8)) people_frame.columnconfigure(0, weight=1) - # Search controls (Last Name) + # Search controls (Last Name) with label under the input (match auto-match style) last_name_search_var = tk.StringVar() - search_row = ttk.Frame(people_frame) - search_row.grid(row=0, column=0, columnspan=2, sticky=(tk.W, tk.E), pady=(0, 6)) - search_entry = ttk.Entry(search_row, textvariable=last_name_search_var, width=20) - search_entry.pack(side=tk.LEFT) - search_btn = ttk.Button(search_row, text="Search", width=8) - search_btn.pack(side=tk.LEFT, padx=(6, 0)) - clear_btn = ttk.Button(search_row, text="Clear", width=6) - clear_btn.pack(side=tk.LEFT, padx=(6, 0)) + search_frame = ttk.Frame(people_frame) + search_frame.grid(row=0, column=0, columnspan=2, sticky=(tk.W, tk.E), pady=(0, 6)) + + # Entry on the left + search_entry = ttk.Entry(search_frame, textvariable=last_name_search_var, width=20) + search_entry.grid(row=0, column=0, sticky=tk.W) + + # Buttons to the right of the entry + buttons_row = ttk.Frame(search_frame) + buttons_row.grid(row=0, column=1, sticky=tk.W, padx=(6, 0)) + search_btn = ttk.Button(buttons_row, text="Search", width=8) + search_btn.pack(side=tk.LEFT, padx=(0, 5)) + clear_btn = ttk.Button(buttons_row, text="Clear", width=6) + clear_btn.pack(side=tk.LEFT) + + # Helper label directly under the entry + last_name_label = ttk.Label(search_frame, text="Type Last Name", font=("Arial", 8), foreground="gray") + last_name_label.grid(row=1, column=0, sticky=tk.W, pady=(2, 0)) people_canvas = tk.Canvas(people_frame, bg='white') people_scrollbar = ttk.Scrollbar(people_frame, orient="vertical", command=people_canvas.yview)