Stabilizza barcode e UDC non scaffalate
This commit is contained in:
@@ -48,6 +48,7 @@ def _build_bypass_session():
|
||||
class BarcodeClientApp:
|
||||
"""Single-window Tk barcode client modeled after the C# legacy form."""
|
||||
|
||||
PALLET_BARCODE_LENGTH = 6
|
||||
NON_SCAFFALATA_BARCODE = "9001000"
|
||||
SHIPPED_BARCODE = "9000000"
|
||||
BARCODE_MAX_WIDTH = 320
|
||||
@@ -65,6 +66,7 @@ class BarcodeClientApp:
|
||||
self.service = BarcodeService(self.repository, session.operator_id)
|
||||
self._pending: Future | None = None
|
||||
self._auto_advance_id: str | None = None
|
||||
self._pallet_auto_focus_id: str | None = None
|
||||
self._status_colors = {
|
||||
"red": "#f4cccc",
|
||||
"green": "#d9ead3",
|
||||
@@ -234,7 +236,7 @@ class BarcodeClientApp:
|
||||
parent.columnconfigure(1, weight=1)
|
||||
if scanned:
|
||||
self.pallet_entry = entry
|
||||
self.scanned_var.trace_add("write", lambda *_: self._limit_var(self.scanned_var, 8))
|
||||
self.scanned_var.trace_add("write", lambda *_: self._on_scanned_var_changed())
|
||||
else:
|
||||
self.destination_entry = entry
|
||||
self.destination_var.trace_add("write", lambda *_: self._limit_var(self.destination_var, 8))
|
||||
@@ -244,6 +246,32 @@ class BarcodeClientApp:
|
||||
if len(value) > max_len:
|
||||
variable.set(value[:max_len])
|
||||
|
||||
def _on_scanned_var_changed(self) -> None:
|
||||
self._limit_var(self.scanned_var, 8)
|
||||
if self._pallet_auto_focus_id is not None:
|
||||
try:
|
||||
self.root.after_cancel(self._pallet_auto_focus_id)
|
||||
except Exception:
|
||||
pass
|
||||
self._pallet_auto_focus_id = None
|
||||
pallet = str(self.scanned_var.get() or "").strip()
|
||||
if len(pallet) < self.PALLET_BARCODE_LENGTH:
|
||||
return
|
||||
self._pallet_auto_focus_id = self.root.after(80, self._auto_focus_destination_after_scan)
|
||||
|
||||
def _auto_focus_destination_after_scan(self) -> None:
|
||||
self._pallet_auto_focus_id = None
|
||||
pallet = str(self.scanned_var.get() or "").strip()
|
||||
if not pallet:
|
||||
return
|
||||
if self._pending is not None and not self._pending.done():
|
||||
return
|
||||
if getattr(self.service.state, "mode", "") == "confirm":
|
||||
return
|
||||
if bool(getattr(self.service.state, "destination_readonly", False)):
|
||||
return
|
||||
self._focus_destination_input()
|
||||
|
||||
def _apply_responsive_geometry(self) -> None:
|
||||
"""Adapt the window size to barcode-sized or desktop-sized screens."""
|
||||
|
||||
@@ -331,6 +359,12 @@ class BarcodeClientApp:
|
||||
except Exception:
|
||||
pass
|
||||
self._auto_advance_id = None
|
||||
if self._pallet_auto_focus_id is not None:
|
||||
try:
|
||||
self.root.after_cancel(self._pallet_auto_focus_id)
|
||||
except Exception:
|
||||
pass
|
||||
self._pallet_auto_focus_id = None
|
||||
self.queue_var.set(state.queue_label)
|
||||
self.destination_var.set(state.destination_barcode)
|
||||
self.scanned_var.set(state.scanned_pallet)
|
||||
@@ -425,7 +459,7 @@ class BarcodeClientApp:
|
||||
def _start_queue(self, id_stato: int) -> None:
|
||||
self._run_async(
|
||||
lambda: self.service.start_priority_queue(id_stato),
|
||||
busy_message="Carico la coda selezionata...",
|
||||
busy_message="In preparazione...",
|
||||
)
|
||||
|
||||
def _submit(self) -> None:
|
||||
@@ -434,7 +468,7 @@ class BarcodeClientApp:
|
||||
scanned_pallet=self.scanned_var.get(),
|
||||
destination_barcode=self.destination_var.get(),
|
||||
),
|
||||
busy_message="Eseguo il movimento...",
|
||||
busy_message="In esecuzione...",
|
||||
)
|
||||
|
||||
def _run_async(self, coro_factory: Callable[[], object], busy_message: str) -> None:
|
||||
|
||||
Reference in New Issue
Block a user