Milestone ultima alpha
This commit is contained in:
@@ -18,6 +18,8 @@ from tkinter import messagebox, ttk
|
||||
from gestione_aree import AsyncRunner
|
||||
from audit_log import log_user_action
|
||||
from busy_overlay import InlineBusyOverlay
|
||||
from locale_text import load_locale_catalog, text as loc_text
|
||||
from ui_theme import theme_color, theme_font, theme_section, theme_value
|
||||
from user_session import UserSession
|
||||
|
||||
try:
|
||||
@@ -449,11 +451,13 @@ class ScaricoDialog(ctk.CTkToplevel):
|
||||
self.on_completed = on_completed
|
||||
self.session = session
|
||||
self.rows: list[ScaricoRow] = []
|
||||
self._busy = InlineBusyOverlay(self)
|
||||
self._theme = theme_section("scarico_dialog", {})
|
||||
self._locale_catalog = load_locale_catalog()
|
||||
self._busy = InlineBusyOverlay(self, self._theme)
|
||||
self._async = AsyncRunner(self)
|
||||
self.rows_tree: ttk.Treeview | None = None
|
||||
|
||||
self.title(f"Scarica {ubicazione}")
|
||||
self.title(loc_text("scarico.title", catalog=self._locale_catalog, default="Scarica {ubicazione}").format(ubicazione=ubicazione))
|
||||
self.resizable(False, False)
|
||||
self.transient(parent)
|
||||
self.protocol("WM_DELETE_WINDOW", self._close)
|
||||
@@ -478,10 +482,19 @@ class ScaricoDialog(ctk.CTkToplevel):
|
||||
top = ctk.CTkFrame(self)
|
||||
top.grid(row=0, column=0, sticky="ew", padx=10, pady=(10, 6))
|
||||
top.grid_columnconfigure(0, weight=1)
|
||||
ctk.CTkLabel(top, text=f"Ubicazione: {self.ubicazione}", font=("", 13, "bold")).grid(
|
||||
ctk.CTkLabel(
|
||||
top,
|
||||
text=loc_text("scarico.label.location", catalog=self._locale_catalog, default="Ubicazione: {ubicazione}").format(ubicazione=self.ubicazione),
|
||||
font=theme_font(self._theme, "header_font", ("Segoe UI", 13, "bold")),
|
||||
).grid(
|
||||
row=0, column=0, sticky="w"
|
||||
)
|
||||
ctk.CTkLabel(top, text="Seleziona le UDC da scaricare", anchor="w").grid(
|
||||
ctk.CTkLabel(
|
||||
top,
|
||||
text=loc_text("scarico.label.select", catalog=self._locale_catalog, default="Seleziona le UDC da scaricare"),
|
||||
anchor="w",
|
||||
font=theme_font(self._theme, "body_font", ("Segoe UI", 10)),
|
||||
).grid(
|
||||
row=1, column=0, sticky="w", pady=(4, 0)
|
||||
)
|
||||
|
||||
@@ -496,8 +509,8 @@ class ScaricoDialog(ctk.CTkToplevel):
|
||||
tree_host.grid_columnconfigure(0, weight=1)
|
||||
|
||||
style = ttk.Style(self)
|
||||
style.configure("Scarico.Treeview", rowheight=28, font=("Segoe UI", 10))
|
||||
style.configure("Scarico.Treeview.Heading", font=("Segoe UI", 10, "bold"))
|
||||
style.configure("Scarico.Treeview", rowheight=28, font=theme_font(self._theme, "tree_body_font", ("Segoe UI", 10)))
|
||||
style.configure("Scarico.Treeview.Heading", font=theme_font(self._theme, "tree_heading_font", ("Segoe UI", 10, "bold")))
|
||||
|
||||
self.rows_tree = ttk.Treeview(
|
||||
tree_host,
|
||||
@@ -507,9 +520,9 @@ class ScaricoDialog(ctk.CTkToplevel):
|
||||
selectmode="none",
|
||||
)
|
||||
self.rows_tree.heading("sel", text="Sel")
|
||||
self.rows_tree.heading("udc", text="UDC")
|
||||
self.rows_tree.heading("last", text="Ultimo inserimento")
|
||||
self.rows_tree.heading("diag", text="Diagnostica")
|
||||
self.rows_tree.heading("udc", text=loc_text("scarico.col.udc", catalog=self._locale_catalog, default="UDC"))
|
||||
self.rows_tree.heading("last", text=loc_text("scarico.col.last_insert", catalog=self._locale_catalog, default="Ultimo inserimento"))
|
||||
self.rows_tree.heading("diag", text=loc_text("scarico.col.diagnostic", catalog=self._locale_catalog, default="Diagnostica"))
|
||||
self.rows_tree.column("sel", width=self.CHECKBOX_COL_W, stretch=False, anchor="center")
|
||||
self.rows_tree.column("udc", width=self.UDC_COL_W, stretch=False, anchor="w")
|
||||
self.rows_tree.column("last", width=self.DATE_COL_W, stretch=False, anchor="w")
|
||||
@@ -524,10 +537,20 @@ class ScaricoDialog(ctk.CTkToplevel):
|
||||
actions = ctk.CTkFrame(self)
|
||||
actions.grid(row=2, column=0, sticky="ew", padx=10, pady=(0, 10))
|
||||
actions.grid_columnconfigure(0, weight=1)
|
||||
ctk.CTkButton(actions, text="scarica", command=self._on_scarica).grid(
|
||||
ctk.CTkButton(
|
||||
actions,
|
||||
text=loc_text("scarico.button.submit", catalog=self._locale_catalog, default="Scarica"),
|
||||
command=self._on_scarica,
|
||||
font=theme_font(self._theme, "button_font", ("Segoe UI", 10, "bold")),
|
||||
).grid(
|
||||
row=0, column=1, padx=(8, 0), pady=8
|
||||
)
|
||||
ctk.CTkButton(actions, text="close", command=self._close).grid(
|
||||
ctk.CTkButton(
|
||||
actions,
|
||||
text=loc_text("scarico.button.close", catalog=self._locale_catalog, default="Chiudi"),
|
||||
command=self._close,
|
||||
font=theme_font(self._theme, "button_font", ("Segoe UI", 10, "bold")),
|
||||
).grid(
|
||||
row=0, column=2, padx=(8, 8), pady=8
|
||||
)
|
||||
|
||||
@@ -606,7 +629,11 @@ class ScaricoDialog(ctk.CTkToplevel):
|
||||
def _err(ex):
|
||||
self._busy.hide()
|
||||
_MODULE_LOGGER.exception(f"Errore caricamento righe scarico idcella={self.idcella}: {ex}")
|
||||
messagebox.showerror("Scarica", f"Caricamento UDC fallito:\n{ex}", parent=self)
|
||||
messagebox.showerror(
|
||||
loc_text("scarico.msg.title", catalog=self._locale_catalog, default="Scarica"),
|
||||
loc_text("scarico.msg.load_error", catalog=self._locale_catalog, default="Caricamento UDC fallito:\n{error}").format(error=ex),
|
||||
parent=self,
|
||||
)
|
||||
self._close()
|
||||
|
||||
self._async.run(
|
||||
@@ -622,7 +649,11 @@ class ScaricoDialog(ctk.CTkToplevel):
|
||||
"""Unload the UDCs selected by the user from the current cell."""
|
||||
selected = [row for row in self.rows if row.selected.get()]
|
||||
if not selected:
|
||||
messagebox.showinfo("Scarica", "Seleziona almeno una UDC da scaricare.", parent=self)
|
||||
messagebox.showinfo(
|
||||
loc_text("scarico.msg.title", catalog=self._locale_catalog, default="Scarica"),
|
||||
loc_text("scarico.msg.select_one", catalog=self._locale_catalog, default="Seleziona almeno una UDC da scaricare."),
|
||||
parent=self,
|
||||
)
|
||||
return
|
||||
|
||||
if not messagebox.askyesno(
|
||||
@@ -693,7 +724,11 @@ class ScaricoDialog(ctk.CTkToplevel):
|
||||
target=self.ubicazione,
|
||||
details={"error": str(ex)},
|
||||
)
|
||||
messagebox.showerror("Scarica", f"Scarico fallito:\n{ex}", parent=self)
|
||||
messagebox.showerror(
|
||||
loc_text("scarico.msg.title", catalog=self._locale_catalog, default="Scarica"),
|
||||
loc_text("scarico.msg.exec_error", catalog=self._locale_catalog, default="Scarico fallito:\n{error}").format(error=ex),
|
||||
parent=self,
|
||||
)
|
||||
|
||||
self._async.run(
|
||||
_job(),
|
||||
|
||||
Reference in New Issue
Block a user