add main application structure with main window and central panel

This commit is contained in:
BYolivia 2025-11-26 19:10:21 +01:00
parent a36cb6c9a2
commit 4097adef18
4 changed files with 258 additions and 2 deletions

View File

@ -1,5 +1,16 @@
if __name__ == "__main__":
print("todo")
import sys
import os
# Agrega la ruta del directorio 'vista' al PYTHONPATH para asegurar que las importaciones funcionen
# Esto es una solución temporal para la ejecución directa si falla 'python -m proyecto'
# Lo más limpio es ejecutar con `python -m nombre_del_paquete` o configurar el IDE.
# Sin embargo, para la ejecución directa en el entorno de desarrollo, lo incluimos:
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from vista.ventana_principal import VentanaPrincipal
if __name__ == "__main__":
app = VentanaPrincipal()
app.mainloop()
else:
print("Cambia el nombre a __main__.py")

View File

@ -0,0 +1,93 @@
import tkinter as tk
from tkinter import ttk
class PanelCentral(ttk.Frame):
"""Contiene el Notebook (subpestañas de T1), el panel de Notas y el panel de Chat."""
def __init__(self, parent, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
# Columna 0: Área Principal (3/4) | Columna 1: Chat (1/4)
self.grid_columnconfigure(0, weight=3)
self.grid_columnconfigure(1, weight=1)
self.grid_rowconfigure(0, weight=1)
self.crear_area_principal_y_notas()
self.crear_panel_chat_y_alumnos()
def crear_area_principal_y_notas(self):
"""Crea el contenedor de las subpestañas de T1 y el panel de notas (inferior izquierda)."""
frame_izquierdo = ttk.Frame(self, style='TFrame')
frame_izquierdo.grid(row=0, column=0, sticky="nsew")
# Fila 0: Subpestañas (4 partes) | Fila 1: Notas (1 parte)
frame_izquierdo.grid_rowconfigure(0, weight=4)
frame_izquierdo.grid_rowconfigure(1, weight=1)
frame_izquierdo.grid_columnconfigure(0, weight=1)
# 1. El Notebook de T1 (Sub-pestañas)
self.crear_sub_pestañas_t1(frame_izquierdo)
# 2. El Panel de Notas (área verde clara inferior izquierda)
panel_notas = ttk.Frame(frame_izquierdo, style='Note.TFrame')
panel_notas.grid(row=1, column=0, sticky="nsew", pady=(5, 0))
ttk.Label(panel_notas, text="Panel para notas informativas y mensajes sobre la ejecución de los hilos.",style='Note.TLabel', anchor="nw", justify=tk.LEFT, padding=10,font=('Arial', 9, 'italic')).pack(expand=True, fill="both")
def crear_sub_pestañas_t1(self, parent_frame):
"""Crea las pestañas internas para la tarea T1 y las empaqueta en la rejilla."""
sub_notebook = ttk.Notebook(parent_frame)
sub_notebook.grid(row=0, column=0, sticky="nsew") # Ocupa Fila 0, Columna 0
sub_tabs = ["Resultados", "Navegador", "Correos", "Tareas", "Alarmas", "Enlaces"]
for i, sub_tab_text in enumerate(sub_tabs):
frame = ttk.Frame(sub_notebook, style='TFrame')
sub_notebook.add(frame, text=sub_tab_text)
# Contenido del área central (simulando el panel rayado)
if sub_tab_text == "Navegador":
# Usamos un widget Text con fondo blanco y un borde sutil para que destaque
contenido_area = tk.Text(frame, wrap="word", padx=15, pady=15,bg='white', relief="groove", borderwidth=1,font=('Consolas', 10), foreground="#555555")
contenido_area.insert(tk.END,">>> ÁREA DE CONTENIDO / VISOR DE NAVEGADOR (Para mostrar resultados o web scraping)\n\n""Este es el espacio dedicado a la visualización de datos o interfaces específicas de cada tarea.")
contenido_area.pack(expand=True, fill="both", padx=5, pady=5)
sub_notebook.select(i)
def crear_panel_chat_y_alumnos(self):
"""Crea el panel de chat, lista de Alumnos y Reproductor de Música (columna derecha)."""
panel_chat = ttk.Frame(self, style='TFrame', padding="10")
panel_chat.grid(row=0, column=1, sticky="nsew")
# Configuración interna del panel de chat
panel_chat.grid_rowconfigure(5, weight=1)
panel_chat.grid_rowconfigure(7, weight=0)
panel_chat.grid_columnconfigure(0, weight=1)
# 1. Título "Chat"
ttk.Label(panel_chat, text="Chat", foreground="#0078d4", font=("Arial", 18, "bold"), style='TLabel').grid(row=0,column=0,pady=(0,10),sticky="w")
# 2. Área de Mensaje
ttk.Label(panel_chat, text="Mensaje", style='TLabel').grid(row=1, column=0, sticky="w")
# Área de texto para el mensaje (el recuadro amarillo)
chat_text = tk.Text(panel_chat, height=6, width=30, bg='#fff8e1', relief="solid", borderwidth=1,font=('Arial', 10))
chat_text.grid(row=2, column=0, sticky="ew", pady=(0, 5))
# Botón Enviar
ttk.Button(panel_chat, text="Enviar", style='Action.TButton').grid(row=3, column=0, pady=(0, 15), sticky="e")
# 3. Lista de Alumnos (Simulación)
for i in range(1, 4):
frame_alumno = ttk.Frame(panel_chat, style='Alumno.TFrame', padding=8)
frame_alumno.grid(row=3 + i, column=0, sticky="ew", pady=5)
frame_alumno.grid_columnconfigure(0, weight=1)
ttk.Label(frame_alumno, text=f"Alumno {i}", font=("Arial", 11, "bold"), style='Alumno.TLabel').grid(row=0,column=0,sticky="w")
ttk.Label(frame_alumno, text="Lorem ipsum dolor sit amet, consectetur adipiscing elit.",wraplength=250, justify=tk.LEFT, style='Alumno.TLabel').grid(row=1, column=0, sticky="w")
# Botón de Recargar/Actualizar
ttk.Button(frame_alumno, text="", width=3, style='Action.TButton').grid(row=0, column=1, rowspan=2, padx=5,sticky="ne")
# 4. Reproductor de Música (Simulado)
musica_frame = ttk.LabelFrame(panel_chat, text="Reproductor Música", padding=10, style='TFrame')
musica_frame.grid(row=8, column=0, sticky="ew", pady=(15, 0))
ttk.Label(musica_frame, text="[ Botones de Play/Stop y Control de Volumen ]", anchor="center",style='TLabel').pack(fill="x", padx=5, pady=5)

View File

@ -0,0 +1,49 @@
import tkinter as tk
from tkinter import ttk
class PanelLateral(ttk.Frame):
"""Contiene el menú de botones y entradas para las tareas de T1."""
def __init__(self, parent, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
self.pack(fill="y", padx=5, pady=5)
# Entrada superior (amarilla)
ttk.Entry(self, width=25, style='Yellow.TEntry').pack(fill="x", pady=10, padx=5)
# 1. Área de Extracción/Navegación
self.crear_seccion(
parent_frame=self,
titulo="",
botones=["Extraer datos", "Navegar", "Buscar API Google"]
)
# 2. Área de Aplicaciones
self.crear_seccion(
parent_frame=self,
titulo="Aplicaciones",
botones=["Visual Code", "App2", "App3"]
)
# 3. Área de Procesos Batch
self.crear_seccion(
parent_frame=self,
titulo="Procesos batch",
botones=["Copias de seguridad"]
)
# Espaciador para empujar los elementos inferiores si los hubiera
tk.Frame(self, height=1).pack(expand=True, fill="both")
def crear_seccion(self, parent_frame, titulo, botones):
"""Función helper para crear secciones de etiquetas y botones."""
if titulo:
ttk.Label(parent_frame, text=titulo).pack(fill="x", pady=(10, 0), padx=5)
frame_botones = ttk.LabelFrame(parent_frame, text="")
frame_botones.pack(fill="x", pady=5, padx=5)
for texto_boton in botones:
# Todos los botones usan el estilo 'Green.TButton' para simular el color
ttk.Button(frame_botones, text=texto_boton, style='Green.TButton').pack(fill="x", pady=5)

View File

@ -0,0 +1,103 @@
import tkinter as tk
from tkinter import ttk
from vista.panel_lateral import PanelLateral
from vista.panel_central import PanelCentral
class VentanaPrincipal(tk.Tk):
"""Clase principal de la aplicación que monta la interfaz con estilos nativos mejorados."""
def __init__(self):
super().__init__()
self.title("Proyecto Integrado - PSP (Estilo Moderno Nativo)")
self.geometry("1200x800")
# 1. Usar el tema 'clam' para un aspecto más plano y moderno
style = ttk.Style()
style.theme_use('clam')
self.config(bg="#f9f9f9") # Fondo global muy claro
self.configurar_estilos(style)
# Configuración de la rejilla principal de la ventana
self.grid_rowconfigure(0, weight=1)
self.grid_rowconfigure(1, weight=0)
self.grid_columnconfigure(0, weight=0) # Panel lateral es de ancho fijo
self.grid_columnconfigure(1, weight=1) # Panel central se expande
self.crear_paneles_principales()
self.crear_barra_inferior()
def configurar_estilos(self, s: ttk.Style):
"""Define estilos visuales personalizados sin dependencias externas."""
# Paleta de Colores
COLOR_FONDO = "#f9f9f9"
COLOR_ACCION = "#0078d4" # Azul principal
COLOR_EXITO = "#4CAF50" # Verde para éxito/notas
COLOR_ADVERTENCIA = "#ffc107" # Amarillo para chat
COLOR_TEXTO = "#333333"
# TFrame y TLabel base (fondo claro)
s.configure('TFrame', background=COLOR_FONDO)
s.configure('TLabel', background=COLOR_FONDO, foreground=COLOR_TEXTO, font=('Arial', 9))
# Botones de Acción (Simulando el color azul/verde de tu diseño)
s.configure('Action.TButton', background=COLOR_ACCION, foreground='white', font=('Arial', 10, 'bold'),
relief='flat', padding=[10, 5])
s.map('Action.TButton', background=[('active', '#005a9e'), ('pressed', '#003c6e')])
# Estilo para el área de notas (simulando el recuadro verde claro)
s.configure('Note.TFrame', background=COLOR_EXITO, borderwidth=0, relief="solid")
s.configure('Note.TLabel', background=COLOR_EXITO, foreground='white', font=('Arial', 9, 'italic'))
# Estilo para el área de chat/entrada (simulando el recuadro amarillo)
s.configure('Chat.TFrame', background=COLOR_ADVERTENCIA)
s.configure('Chat.TLabel', background=COLOR_ADVERTENCIA)
# Estilo para los recuadros de Alumnos (fondo blanco con borde)
s.configure('Alumno.TFrame', background='white', borderwidth=1, relief='solid')
s.configure('Alumno.TLabel', background='white', foreground=COLOR_TEXTO)
# Configuración de las pestañas (Notebook interno - subpestañas)
s.configure('TNotebook.Tab', padding=[10, 5], font=('Arial', 10, 'bold'))
s.map('TNotebook.Tab', background=[('selected', COLOR_FONDO)], foreground=[('selected', COLOR_ACCION)])
def crear_paneles_principales(self):
"""Ensambla el panel lateral y el panel central en la rejilla."""
# Panel Lateral (columna 0)
self.panel_lateral = PanelLateral(self)
self.panel_lateral.grid(row=0, column=0, sticky="nswe", padx=(10, 5), pady=10)
# Panel Central (columna 1)
self.panel_central = PanelCentral(self)
self.panel_central.grid(row=0, column=1, sticky="nswe", padx=(5, 10), pady=10)
def crear_barra_inferior(self):
"""Crea la barra de estado o información inferior."""
frame_inferior = ttk.Frame(self, relief="flat", padding=[10, 5, 10, 5], style='TFrame', borderwidth=0)
frame_inferior.grid(row=1, column=0, columnspan=2, sticky="ew")
frame_inferior.grid_columnconfigure(0, weight=1)
frame_inferior.grid_columnconfigure(1, weight=1)
frame_inferior.grid_columnconfigure(2, weight=1)
# Elementos de la barra inferior (más discretos)
# Correos sin leer
frame_correo = ttk.Frame(frame_inferior, style='TFrame')
frame_correo.grid(row=0, column=0, sticky="w")
ttk.Label(frame_correo, text="Correos sin leer: 0", style='TLabel').pack(side="left")
ttk.Button(frame_correo, text="", width=3, style='Action.TButton').pack(side="left", padx=5)
# Temperatura local
frame_temp = ttk.Frame(frame_inferior, style='TFrame')
frame_temp.grid(row=0, column=1)
ttk.Button(frame_temp, text="", width=3, style='Action.TButton').pack(side="left", padx=5)
ttk.Label(frame_temp, text="Temperatura local: --", style='TLabel').pack(side="left")
# Fecha y Hora
frame_fecha = ttk.Frame(frame_inferior, style='TFrame')
frame_fecha.grid(row=0, column=2, sticky="e")
ttk.Label(frame_fecha, text="Fecha Día y Hora: --/--/--", style='TLabel').pack(side="left")