migrazione verso gitea
This commit is contained in:
82
main.py
82
main.py
@@ -1,16 +1,22 @@
|
||||
"""Application entry point for the warehouse desktop tool.
|
||||
|
||||
This module wires together the shared async database client, the global
|
||||
background event loop and the different Tk/CustomTkinter windows exposed by the
|
||||
project.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import asyncio
|
||||
import sys
|
||||
import tkinter as tk
|
||||
|
||||
import customtkinter as ctk
|
||||
|
||||
from async_msssql_query import AsyncMSSQLClient, make_mssql_dsn
|
||||
from async_loop_singleton import get_global_loop
|
||||
|
||||
from async_msssql_query import AsyncMSSQLClient, make_mssql_dsn
|
||||
from layout_window import open_layout_window
|
||||
from view_celle_multiple import open_celle_multiple_window
|
||||
from reset_corsie import open_reset_corsie_window
|
||||
from search_pallets import open_search_window
|
||||
from view_celle_multiple import open_celle_multiple_window
|
||||
|
||||
# Try factory, else frame, else app (senza passare conn_str all'App)
|
||||
try:
|
||||
@@ -18,22 +24,22 @@ try:
|
||||
except Exception:
|
||||
try:
|
||||
from gestione_pickinglist import GestionePickingListFrame as _PLFrame
|
||||
import customtkinter as ctk
|
||||
|
||||
def create_pickinglist_frame(parent, db_client=None, conn_str=None):
|
||||
"""Build the picking list UI using the frame-based fallback."""
|
||||
ctk.set_appearance_mode("light")
|
||||
ctk.set_default_color_theme("green")
|
||||
return _PLFrame(parent, db_client=db_client, conn_str=conn_str)
|
||||
except Exception:
|
||||
# Ultimo fallback: alcune versioni espongono solo la App e NON accettano conn_str
|
||||
# Ultimo fallback: alcune versioni espongono solo la App e NON accettano parametri
|
||||
from gestione_pickinglist import GestionePickingListApp as _PLApp
|
||||
|
||||
def create_pickinglist_frame(parent, db_client=None, conn_str=None):
|
||||
app = _PLApp() # <-- niente parametri qui
|
||||
"""Fallback used only by legacy app-style picking list implementations."""
|
||||
app = _PLApp()
|
||||
app.mainloop()
|
||||
return tk.Frame(parent)
|
||||
|
||||
|
||||
|
||||
# ---- Config ----
|
||||
SERVER = r"mde3\gesterp"
|
||||
DBNAME = "Mediseawall"
|
||||
@@ -46,13 +52,16 @@ if sys.platform.startswith("win"):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Create ONE global loop and make it the default everywhere
|
||||
# Create one global loop and make it the default everywhere.
|
||||
_loop = get_global_loop()
|
||||
asyncio.set_event_loop(_loop)
|
||||
|
||||
# --- DPI tracker compatibility ---
|
||||
|
||||
def _noop(*args, **kwargs):
|
||||
"""Compatibility no-op used when optional Tk DPI hooks are missing."""
|
||||
return None
|
||||
|
||||
|
||||
if not hasattr(tk.Toplevel, "block_update_dimensions_event"):
|
||||
tk.Toplevel.block_update_dimensions_event = _noop # type: ignore[attr-defined]
|
||||
if not hasattr(tk.Toplevel, "unblock_update_dimensions_event"):
|
||||
@@ -63,31 +72,30 @@ db_app = AsyncMSSQLClient(dsn_app)
|
||||
|
||||
|
||||
def open_pickinglist_window(parent: tk.Misc, db_client: AsyncMSSQLClient):
|
||||
"""Open the picking list window while minimizing initial flicker."""
|
||||
win = ctk.CTkToplevel(parent)
|
||||
win.title("Gestione Picking List")
|
||||
win.geometry("1200x700+0+100")
|
||||
win.minsize(1000, 560)
|
||||
|
||||
# 1) tieni la toplevel fuori scena mentre componi
|
||||
# Keep the toplevel hidden while its content is being created.
|
||||
try:
|
||||
win.withdraw()
|
||||
# opzionale: rendila invisibile anche se il WM la “intr intravede”
|
||||
win.attributes("-alpha", 0.0)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 2) costruisci tutto il contenuto
|
||||
frame = create_pickinglist_frame(win, db_client=db_client)
|
||||
try:
|
||||
frame.pack(fill="both", expand=True)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 3) quando è pronta, mostra "a scatto" davanti, senza topmost
|
||||
# Show the window only when the layout is ready.
|
||||
try:
|
||||
win.update_idletasks()
|
||||
try:
|
||||
win.transient(parent) # z-order legato alla main
|
||||
win.transient(parent)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
@@ -99,7 +107,6 @@ def open_pickinglist_window(parent: tk.Misc, db_client: AsyncMSSQLClient):
|
||||
win.focus_force()
|
||||
except Exception:
|
||||
pass
|
||||
# ripristina opacità
|
||||
try:
|
||||
win.attributes("-alpha", 1.0)
|
||||
except Exception:
|
||||
@@ -112,10 +119,11 @@ def open_pickinglist_window(parent: tk.Misc, db_client: AsyncMSSQLClient):
|
||||
return win
|
||||
|
||||
|
||||
|
||||
|
||||
class Launcher(ctk.CTk):
|
||||
"""Main launcher window that exposes the available warehouse tools."""
|
||||
|
||||
def __init__(self):
|
||||
"""Create the launcher toolbar and wire every button to a feature window."""
|
||||
super().__init__()
|
||||
self.title("Warehouse 1.0.0")
|
||||
self.geometry("1200x70+0+0")
|
||||
@@ -123,21 +131,37 @@ class Launcher(ctk.CTk):
|
||||
wrap = ctk.CTkFrame(self)
|
||||
wrap.pack(pady=10, fill="x")
|
||||
|
||||
ctk.CTkButton(wrap, text="Gestione Corsie",
|
||||
command=lambda: open_reset_corsie_window(self, db_app)).grid(row=0, column=0, padx=6, pady=6, sticky="ew")
|
||||
ctk.CTkButton(wrap, text="Gestione Layout",
|
||||
command=lambda: open_layout_window(self, db_app)).grid(row=0, column=1, padx=6, pady=6, sticky="ew")
|
||||
ctk.CTkButton(wrap, text="UDC Fantasma",
|
||||
command=lambda: open_celle_multiple_window(self, db_app)).grid(row=0, column=2, padx=6, pady=6, sticky="ew")
|
||||
ctk.CTkButton(wrap, text="Ricerca UDC",
|
||||
command=lambda: open_search_window(self, db_app)).grid(row=0, column=3, padx=6, pady=6, sticky="ew")
|
||||
ctk.CTkButton(wrap, text="Gestione Picking List",
|
||||
command=lambda: open_pickinglist_window(self, db_app)).grid(row=0, column=4, padx=6, pady=6, sticky="ew")
|
||||
ctk.CTkButton(
|
||||
wrap,
|
||||
text="Gestione Corsie",
|
||||
command=lambda: open_reset_corsie_window(self, db_app),
|
||||
).grid(row=0, column=0, padx=6, pady=6, sticky="ew")
|
||||
ctk.CTkButton(
|
||||
wrap,
|
||||
text="Gestione Layout",
|
||||
command=lambda: open_layout_window(self, db_app),
|
||||
).grid(row=0, column=1, padx=6, pady=6, sticky="ew")
|
||||
ctk.CTkButton(
|
||||
wrap,
|
||||
text="UDC Fantasma",
|
||||
command=lambda: open_celle_multiple_window(self, db_app),
|
||||
).grid(row=0, column=2, padx=6, pady=6, sticky="ew")
|
||||
ctk.CTkButton(
|
||||
wrap,
|
||||
text="Ricerca UDC",
|
||||
command=lambda: open_search_window(self, db_app),
|
||||
).grid(row=0, column=3, padx=6, pady=6, sticky="ew")
|
||||
ctk.CTkButton(
|
||||
wrap,
|
||||
text="Gestione Picking List",
|
||||
command=lambda: open_pickinglist_window(self, db_app),
|
||||
).grid(row=0, column=4, padx=6, pady=6, sticky="ew")
|
||||
|
||||
for i in range(5):
|
||||
wrap.grid_columnconfigure(i, weight=1)
|
||||
|
||||
def _on_close():
|
||||
"""Dispose shared resources before closing the launcher."""
|
||||
try:
|
||||
fut = asyncio.run_coroutine_threadsafe(db_app.dispose(), _loop)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user