Discover dialog: 2s default wait, Enter starts discovery
Focus the dialog on open so Enter works without clicking first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+11
-2
@@ -201,7 +201,7 @@ class DiscoverDialog:
|
||||
hdr, text="Discover", command=self._do_discover, width=10)
|
||||
self._btn_discover.pack(side=tk.RIGHT)
|
||||
|
||||
self._wait_var = tk.StringVar(value="10")
|
||||
self._wait_var = tk.StringVar(value="2")
|
||||
ttk.Entry(hdr, textvariable=self._wait_var, width=4, justify="center").pack(
|
||||
side=tk.RIGHT, padx=(0, 4))
|
||||
ttk.Label(hdr, text="Wait (s):").pack(side=tk.RIGHT, padx=(8, 2))
|
||||
@@ -248,14 +248,23 @@ class DiscoverDialog:
|
||||
self._btn_connect.pack(side=tk.RIGHT, padx=(0, 8))
|
||||
|
||||
self._dlg.bind("<Escape>", lambda e: self._dlg.destroy())
|
||||
self._dlg.bind("<Return>", self._on_return)
|
||||
|
||||
self._dlg.update_idletasks()
|
||||
x = parent.winfo_x() + (parent.winfo_width() - self._dlg.winfo_width()) // 2
|
||||
y = parent.winfo_y() + (parent.winfo_height() - self._dlg.winfo_height()) // 2
|
||||
self._dlg.geometry(f"+{x}+{y}")
|
||||
self._dlg.lift()
|
||||
self._dlg.focus_force()
|
||||
self._btn_discover.focus_set()
|
||||
|
||||
# ── Discovery ──────────────────────────────────────────────────
|
||||
|
||||
def _on_return(self, event=None):
|
||||
if str(self._btn_discover.cget("state")) != "disabled":
|
||||
self._do_discover()
|
||||
return "break"
|
||||
|
||||
def _do_discover(self):
|
||||
try:
|
||||
port_int = int(self._port_var.get().strip())
|
||||
@@ -265,7 +274,7 @@ class DiscoverDialog:
|
||||
try:
|
||||
wait_time = max(1, min(60, int(self._wait_var.get().strip())))
|
||||
except ValueError:
|
||||
wait_time = 10
|
||||
wait_time = 2
|
||||
|
||||
self._btn_discover.config(state="disabled")
|
||||
self._status_label.config(text="Discovering devices...", foreground="#666666")
|
||||
|
||||
Reference in New Issue
Block a user