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:
2026-10-05 07:39:24 +03:00
co-authored by Claude Opus 5.5
parent 894fdb7eb5
commit 6b23bafffc
2 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ so later rebinding would only ever be seen by the module that did it.
import configparser
import os
VERSION = "0.0.0.142"
VERSION = "0.0.0.143"
PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties")
DEFAULT_GRID_SIZE = 10
DEFAULT_ADD_TIMESTAMP = True
+11 -2
View File
@@ -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")