Enhance PhotoTagger GUI by standardizing canvas configurations and improving the unmatch face button. Set consistent background colors for canvases, and implement a new clickable 'X' button with hover effects for better user interaction. This update aims to improve visual consistency and usability across the interface.
This commit is contained in:
parent
199a75098d
commit
68ec18b822
@ -4376,6 +4376,11 @@ class PhotoTagger:
|
||||
|
||||
style = ttk.Style()
|
||||
canvas_bg_color = style.lookup('TFrame', 'background') or '#d9d9d9'
|
||||
# Match auto-match UI: set gray background for left canvas and remove highlight border
|
||||
try:
|
||||
people_canvas.configure(bg=canvas_bg_color, highlightthickness=0)
|
||||
except Exception:
|
||||
pass
|
||||
faces_canvas = tk.Canvas(faces_frame, bg=canvas_bg_color, highlightthickness=0)
|
||||
faces_scrollbar = ttk.Scrollbar(faces_frame, orient="vertical", command=faces_canvas.yview)
|
||||
faces_inner = ttk.Frame(faces_canvas)
|
||||
@ -4684,17 +4689,28 @@ class PhotoTagger:
|
||||
face_frame = ttk.Frame(tile)
|
||||
face_frame.grid(row=0, column=0)
|
||||
|
||||
canvas = tk.Canvas(face_frame, width=130, height=130, bg='white')
|
||||
canvas = tk.Canvas(face_frame, width=130, height=130, bg=canvas_bg_color, highlightthickness=0)
|
||||
canvas.grid(row=0, column=0)
|
||||
if thumb is not None:
|
||||
canvas.create_image(65, 65, image=thumb)
|
||||
else:
|
||||
canvas.create_text(65, 65, text="🖼️", fill="gray")
|
||||
|
||||
# X button to unmatch face
|
||||
x_btn = ttk.Button(face_frame, text="✖", width=2,
|
||||
command=lambda fid=face_id: unmatch_face(fid))
|
||||
x_btn.place(x=110, y=5) # Position in top-right corner
|
||||
# X button to unmatch face - pin exactly to the canvas' top-right corner
|
||||
x_canvas = tk.Canvas(face_frame, width=12, height=12, bg='red',
|
||||
highlightthickness=0, relief="flat")
|
||||
x_canvas.create_text(6, 6, text="✖", fill="white", font=("Arial", 8, "bold"))
|
||||
# Click handler
|
||||
x_canvas.bind("<Button-1>", lambda e, fid=face_id: unmatch_face(fid))
|
||||
# Hover highlight: change bg, show white outline, and hand cursor
|
||||
x_canvas.bind("<Enter>", lambda e, c=x_canvas: c.configure(bg="#cc0000", highlightthickness=1, highlightbackground="white", cursor="hand2"))
|
||||
x_canvas.bind("<Leave>", lambda e, c=x_canvas: c.configure(bg="red", highlightthickness=0, cursor=""))
|
||||
# Anchor to the canvas' top-right regardless of layout/size
|
||||
try:
|
||||
x_canvas.place(in_=canvas, relx=1.0, x=0, y=0, anchor='ne')
|
||||
except Exception:
|
||||
# Fallback to absolute coords if relative placement fails
|
||||
x_canvas.place(x=118, y=0)
|
||||
|
||||
ttk.Label(tile, text=f"ID {face_id}", foreground="gray").grid(row=1, column=0)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user