From d19666ba0e264f00611d9fd2d0e6884044eaf3a7 Mon Sep 17 00:00:00 2001 From: Claude Agent Date: Thu, 16 Apr 2026 06:19:32 +0000 Subject: [PATCH] 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) --- src/atm/calibrate.py | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/atm/calibrate.py b/src/atm/calibrate.py index 742c893..23864c3 100644 --- a/src/atm/calibrate.py +++ b/src/atm/calibrate.py @@ -219,37 +219,49 @@ class _CalibrationWizard: } self._tmp: dict = {} # first-click holders - # --- layout --- - screen_w = self._root.winfo_screenwidth() - 100 - screen_h = self._root.winfo_screenheight() - 200 + # --- layout (force geometry; Tk defaults to a tiny window otherwise) --- + self._root.update_idletasks() + screen_w = self._root.winfo_screenwidth() + screen_h = self._root.winfo_screenheight() 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_h = int(orig_h * self._scale) scaled = pil_img.resize((disp_w, disp_h)) self._tkimg = ImageTk.PhotoImage(scaled) - self._status = tk.Label( - self._root, text="", font=("Arial", 13), fg="white", bg="#2b7de9", - padx=8, pady=6, anchor="w", - ) - self._status.pack(fill="x") + win_w = disp_w + win_h = disp_h + 90 + self._root.geometry(f"{win_w}x{win_h}+10+10") + self._root.minsize(600, 400) - bar = tk.Frame(self._root) - bar.pack(fill="x") + self._status = tk.Label( + 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.pack(side="left", padx=4, pady=4) 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._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._canvas = tk.Canvas( self._root, width=disp_w, height=disp_h, bg="#222", cursor="crosshair", 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.bind("", self._on_click)