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:
+1
-1
@@ -8,7 +8,7 @@ so later rebinding would only ever be seen by the module that did it.
|
|||||||
import configparser
|
import configparser
|
||||||
import os
|
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")
|
PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties")
|
||||||
DEFAULT_GRID_SIZE = 10
|
DEFAULT_GRID_SIZE = 10
|
||||||
DEFAULT_ADD_TIMESTAMP = True
|
DEFAULT_ADD_TIMESTAMP = True
|
||||||
|
|||||||
+11
-2
@@ -201,7 +201,7 @@ class DiscoverDialog:
|
|||||||
hdr, text="Discover", command=self._do_discover, width=10)
|
hdr, text="Discover", command=self._do_discover, width=10)
|
||||||
self._btn_discover.pack(side=tk.RIGHT)
|
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(
|
ttk.Entry(hdr, textvariable=self._wait_var, width=4, justify="center").pack(
|
||||||
side=tk.RIGHT, padx=(0, 4))
|
side=tk.RIGHT, padx=(0, 4))
|
||||||
ttk.Label(hdr, text="Wait (s):").pack(side=tk.RIGHT, padx=(8, 2))
|
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._btn_connect.pack(side=tk.RIGHT, padx=(0, 8))
|
||||||
|
|
||||||
self._dlg.bind("<Escape>", lambda e: self._dlg.destroy())
|
self._dlg.bind("<Escape>", lambda e: self._dlg.destroy())
|
||||||
|
self._dlg.bind("<Return>", self._on_return)
|
||||||
|
|
||||||
self._dlg.update_idletasks()
|
self._dlg.update_idletasks()
|
||||||
x = parent.winfo_x() + (parent.winfo_width() - self._dlg.winfo_width()) // 2
|
x = parent.winfo_x() + (parent.winfo_width() - self._dlg.winfo_width()) // 2
|
||||||
y = parent.winfo_y() + (parent.winfo_height() - self._dlg.winfo_height()) // 2
|
y = parent.winfo_y() + (parent.winfo_height() - self._dlg.winfo_height()) // 2
|
||||||
self._dlg.geometry(f"+{x}+{y}")
|
self._dlg.geometry(f"+{x}+{y}")
|
||||||
|
self._dlg.lift()
|
||||||
|
self._dlg.focus_force()
|
||||||
|
self._btn_discover.focus_set()
|
||||||
|
|
||||||
# ── Discovery ──────────────────────────────────────────────────
|
# ── Discovery ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
def _on_return(self, event=None):
|
||||||
|
if str(self._btn_discover.cget("state")) != "disabled":
|
||||||
|
self._do_discover()
|
||||||
|
return "break"
|
||||||
|
|
||||||
def _do_discover(self):
|
def _do_discover(self):
|
||||||
try:
|
try:
|
||||||
port_int = int(self._port_var.get().strip())
|
port_int = int(self._port_var.get().strip())
|
||||||
@@ -265,7 +274,7 @@ class DiscoverDialog:
|
|||||||
try:
|
try:
|
||||||
wait_time = max(1, min(60, int(self._wait_var.get().strip())))
|
wait_time = max(1, min(60, int(self._wait_var.get().strip())))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
wait_time = 10
|
wait_time = 2
|
||||||
|
|
||||||
self._btn_discover.config(state="disabled")
|
self._btn_discover.config(state="disabled")
|
||||||
self._status_label.config(text="Discovering devices...", foreground="#666666")
|
self._status_label.config(text="Discovering devices...", foreground="#666666")
|
||||||
|
|||||||
Reference in New Issue
Block a user