From 0252a0c0e341fc9250c4dcbdeee49d03fc9ea177 Mon Sep 17 00:00:00 2001 From: Marcel Peterkau Date: Fri, 4 Sep 2026 22:05:26 +0200 Subject: [PATCH] Wait for the options window before grabbing it OptionsDialog called grab_set() straight after transient(), before the window was on screen. Tk refuses a grab on a window that is not viewable yet, and this dialog builds enough tabs that it regularly still is not -- the options UI tests failed with "grab failed: window not viewable" once the mail-template tab grew another entry. The grab now waits for an idle callback, which is what the other dialogs in the codebase already do. Co-Authored-By: Claude Opus 5 --- src/ccma/ui/options_dialog.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ccma/ui/options_dialog.py b/src/ccma/ui/options_dialog.py index 5033ec9..3d8b682 100644 --- a/src/ccma/ui/options_dialog.py +++ b/src/ccma/ui/options_dialog.py @@ -86,7 +86,10 @@ class OptionsDialog(tk.Toplevel): self.mail_template_snippets: dict[str, str] = {} self.title("Optionen") self.transient(master.winfo_toplevel()) - self.grab_set() + # Tk refuses a grab on a window that is not on screen yet ("window not + # viewable"), and this dialog builds enough tabs to still be unmapped here -- + # so the grab waits for the window like it does in the other dialogs. + self.after_idle(self.grab_set) self.resizable(True, True) self._build_ui() self.bind("", lambda _event: self.destroy())