feat: Introduce build and installation scripts for IPSExtractor, including a batch file for PyInstaller and Inno Setup integration, and add application preferences management for document types and retry logic in the GUI.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Pestaña de Configuración de la aplicación GUI."""
|
||||
import customtkinter as ctk
|
||||
from gui.styles import AppStyles
|
||||
from application.app_prefs import get_allowed_document_types, normalize_document_types
|
||||
|
||||
|
||||
class SettingsTab:
|
||||
@@ -20,6 +21,7 @@ class SettingsTab:
|
||||
self._setup_layout()
|
||||
self._create_api_section()
|
||||
self._create_processing_section()
|
||||
self._create_document_types_section()
|
||||
self._create_save_button()
|
||||
|
||||
def _setup_layout(self):
|
||||
@@ -55,18 +57,18 @@ class SettingsTab:
|
||||
|
||||
self.combo_model = ctk.CTkComboBox(
|
||||
self.frame_api,
|
||||
values=["5.1", "4.1", "4.1 mini", "4.1 nano"],
|
||||
values=["5.4", "5.4-mini", "5.4-nano", "5.2", "4.1-mini"],
|
||||
width=250,
|
||||
font=self.fonts["ui"]
|
||||
)
|
||||
self.combo_model.grid(row=1, column=1, padx=15, pady=10, sticky="w")
|
||||
self.combo_model.set("4.1")
|
||||
self.combo_model.set("5.4")
|
||||
|
||||
# Texto de ayuda
|
||||
help_text = (
|
||||
"ℹ 4.1 mini: Muy rápido (recomendado)\n"
|
||||
"ℹ 4.1: Estándar (balanceado)\n"
|
||||
"ℹ 5.1: Lento pero mayor razonamiento"
|
||||
"ℹ 5.4: Modelo predeterminado\n"
|
||||
"ℹ 5.4-mini / 4.1-mini: opciones más rápidas\n"
|
||||
"ℹ 5.4-nano: opción más económica"
|
||||
)
|
||||
lbl_help = ctk.CTkLabel(
|
||||
self.frame_api,
|
||||
@@ -119,6 +121,36 @@ class SettingsTab:
|
||||
text_color="orange"
|
||||
)
|
||||
lbl_conc_warn.grid(row=2, column=0, columnspan=2, padx=15, pady=(0, 10), sticky="w")
|
||||
|
||||
def _create_document_types_section(self):
|
||||
"""Crea la sección editable de tipos documentales permitidos."""
|
||||
self.frame_doc_types = ctk.CTkFrame(self.settings_container)
|
||||
self.frame_doc_types.grid(row=2, column=0, sticky="ew", padx=5, pady=5)
|
||||
self.frame_doc_types.grid_columnconfigure(0, weight=1)
|
||||
|
||||
lbl_title = ctk.CTkLabel(
|
||||
self.frame_doc_types,
|
||||
text="Tipos de Documento Permitidos",
|
||||
font=self.fonts["section"]
|
||||
)
|
||||
lbl_title.grid(row=0, column=0, sticky="w", padx=15, pady=(10, 4))
|
||||
|
||||
lbl_help = ctk.CTkLabel(
|
||||
self.frame_doc_types,
|
||||
text="Escríbelos separados por comas. Se usarán en documento_forzate. NIT se ignorará automáticamente.",
|
||||
font=self.fonts["italic_small"],
|
||||
text_color=self.colors["gray_light"],
|
||||
justify="left"
|
||||
)
|
||||
lbl_help.grid(row=1, column=0, sticky="w", padx=15, pady=(0, 6))
|
||||
|
||||
self.allowed_doc_types_entry = ctk.CTkEntry(
|
||||
self.frame_doc_types,
|
||||
font=self.fonts["ui"],
|
||||
placeholder_text="CC, TI, CE, RC, PA, PPT, PEP, EPT, NUIP"
|
||||
)
|
||||
self.allowed_doc_types_entry.grid(row=2, column=0, sticky="ew", padx=15, pady=(0, 10))
|
||||
self.set_allowed_document_types(list(get_allowed_document_types()))
|
||||
|
||||
def _create_save_button(self):
|
||||
"""Crea el botón de guardar configuración."""
|
||||
@@ -128,7 +160,7 @@ class SettingsTab:
|
||||
font=self.fonts["ui"],
|
||||
height=35
|
||||
)
|
||||
self.btn_save_settings.grid(row=2, column=0, padx=15, pady=15, sticky="ew")
|
||||
self.btn_save_settings.grid(row=3, column=0, padx=15, pady=15, sticky="ew")
|
||||
|
||||
# --- API Pública ---
|
||||
|
||||
@@ -154,10 +186,22 @@ class SettingsTab:
|
||||
def set_concurrency_limit(self, limit: int) -> None:
|
||||
"""Establece el límite de concurrencia."""
|
||||
self.concurrency_var.set(str(limit))
|
||||
|
||||
def get_allowed_document_types(self) -> list[str]:
|
||||
"""Devuelve la lista editable de tipos documentales válidos."""
|
||||
raw = self.allowed_doc_types_entry.get().strip()
|
||||
values = [part.strip() for part in raw.split(",")]
|
||||
return normalize_document_types(values)
|
||||
|
||||
def set_allowed_document_types(self, values: list[str]) -> None:
|
||||
"""Establece la lista de tipos documentales válidos."""
|
||||
self.allowed_doc_types_entry.delete(0, "end")
|
||||
self.allowed_doc_types_entry.insert(0, ", ".join(normalize_document_types(values)))
|
||||
|
||||
def enable_controls(self, enabled: bool):
|
||||
"""Habilita o deshabilita los controles."""
|
||||
state = "normal" if enabled else "disabled"
|
||||
self.combo_model.configure(state=state)
|
||||
self.concurrency_entry.configure(state=state)
|
||||
self.allowed_doc_types_entry.configure(state=state)
|
||||
self.btn_save_settings.configure(state=state)
|
||||
|
||||
Reference in New Issue
Block a user