fix(calibrate): force wizard window geometry; image now fills canvas

Root cause: Tk created default-size (~200x200) window; canvas rendered but cropped.
Fix: compute display dims + call root.geometry() explicitly + fill=both expand=True.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-04-16 06:19:32 +00:00
parent f6ffeb22ec
commit d19666ba0e

View File

@@ -219,37 +219,49 @@ class _CalibrationWizard:
} }
self._tmp: dict = {} # first-click holders self._tmp: dict = {} # first-click holders
# --- layout --- # --- layout (force geometry; Tk defaults to a tiny window otherwise) ---
screen_w = self._root.winfo_screenwidth() - 100 self._root.update_idletasks()
screen_h = self._root.winfo_screenheight() - 200 screen_w = self._root.winfo_screenwidth()
screen_h = self._root.winfo_screenheight()
orig_w, orig_h = pil_img.size orig_w, orig_h = pil_img.size
self._scale = min(screen_w / orig_w, screen_h / orig_h, 1.0) # Reserve ~110px for status bar + button row + window chrome.
avail_w = max(400, screen_w - 40)
avail_h = max(400, screen_h - 140)
self._scale = min(avail_w / orig_w, avail_h / orig_h, 1.0)
disp_w = int(orig_w * self._scale) disp_w = int(orig_w * self._scale)
disp_h = int(orig_h * self._scale) disp_h = int(orig_h * self._scale)
scaled = pil_img.resize((disp_w, disp_h)) scaled = pil_img.resize((disp_w, disp_h))
self._tkimg = ImageTk.PhotoImage(scaled) self._tkimg = ImageTk.PhotoImage(scaled)
self._status = tk.Label( win_w = disp_w
self._root, text="", font=("Arial", 13), fg="white", bg="#2b7de9", win_h = disp_h + 90
padx=8, pady=6, anchor="w", self._root.geometry(f"{win_w}x{win_h}+10+10")
) self._root.minsize(600, 400)
self._status.pack(fill="x")
bar = tk.Frame(self._root) self._status = tk.Label(
bar.pack(fill="x") self._root, text="", font=("Arial", 13, "bold"), fg="white", bg="#2b7de9",
padx=10, pady=8, anchor="w",
)
self._status.pack(fill="x", side="top")
bar = tk.Frame(self._root, bg="#eee")
bar.pack(fill="x", side="top")
self._back_btn = tk.Button(bar, text="← Back", command=self._back) self._back_btn = tk.Button(bar, text="← Back", command=self._back)
self._back_btn.pack(side="left", padx=4, pady=4) self._back_btn.pack(side="left", padx=4, pady=4)
self._skip_btn = tk.Button(bar, text="Skip (can't find)", command=self._skip) self._skip_btn = tk.Button(bar, text="Skip (can't find)", command=self._skip)
self._skip_btn.pack(side="left", padx=4, pady=4) self._skip_btn.pack(side="left", padx=4, pady=4)
self._save_btn = tk.Button(bar, text="💾 Save", command=self._save, state="disabled") self._save_btn = tk.Button(
bar, text="💾 Save", command=self._save, state="disabled",
bg="#2ecc71", fg="white", activebackground="#27ae60",
)
self._save_btn.pack(side="right", padx=4, pady=4) self._save_btn.pack(side="right", padx=4, pady=4)
self._canvas = tk.Canvas( self._canvas = tk.Canvas(
self._root, width=disp_w, height=disp_h, bg="#222", cursor="crosshair", self._root, width=disp_w, height=disp_h, bg="#222", cursor="crosshair",
highlightthickness=0, highlightthickness=0,
) )
self._canvas.pack() self._canvas.pack(side="top", fill="both", expand=True)
self._canvas.create_image(0, 0, anchor="nw", image=self._tkimg) self._canvas.create_image(0, 0, anchor="nw", image=self._tkimg)
self._canvas.bind("<Button-1>", self._on_click) self._canvas.bind("<Button-1>", self._on_click)