diff --git a/app/__pycache__/panel_derecho.cpython-313.pyc b/app/__pycache__/panel_derecho.cpython-313.pyc new file mode 100644 index 0000000..9f34f87 Binary files /dev/null and b/app/__pycache__/panel_derecho.cpython-313.pyc differ diff --git a/app/panel_derecho.py b/app/panel_derecho.py new file mode 100644 index 0000000..2e5fb7c --- /dev/null +++ b/app/panel_derecho.py @@ -0,0 +1,121 @@ +import tkinter as tk +from tkinter import messagebox +import threading +import pygame # Para reproducir música + + +class PanelDerecho: + def __init__(self, frame): + # Inicializar el reproductor de música + pygame.mixer.init() + + # Asociar el frame del panel derecho + self.frame = frame + self.frame.configure(bg="lightblue", width=200) + self.frame.grid_propagate(False) + self.frame.columnconfigure(0, weight=1) + + # Título del chat + chat_label = tk.Label(self.frame, text="Chat", font=("Helvetica", 12, "bold"), bg="white", fg="red") + chat_label.grid(row=0, column=0, sticky="ew", pady=5, padx=5) + + # Área de entrada de mensaje + mensaje_label = tk.Label(self.frame, text="Mensaje", font=("Helvetica", 10), bg="lightblue") + mensaje_label.grid(row=1, column=0, sticky="w", padx=5) + self.entrada_mensaje = tk.Text(self.frame, height=5, bg="lightyellow", wrap="word") + self.entrada_mensaje.grid(row=2, column=0, sticky="ew", padx=5, pady=5) + + # Botón de enviar + boton_enviar = tk.Button(self.frame, text="Enviar", bg="lightgreen", command=self.enviar_mensaje_thread) + boton_enviar.grid(row=3, column=0, pady=5, padx=5, sticky="ew") + + # Listado de mensajes + mensajes_frame = tk.Frame(self.frame, bg="white", bd=2, relief="sunken") + mensajes_frame.grid(row=4, column=0, sticky="nsew", padx=5, pady=5) + mensajes_frame.columnconfigure(0, weight=1) + self.mensajes_frame = mensajes_frame + + # Mensajes iniciales + self.mensajes = [ + {"alumno": "Alumno 1", "texto": "Voy to mal con el trabajo final de DAM, pero seguro que chatgpt me lo hace en nada asiq de chill."}, + {"alumno": "Alumno 2", "texto": "Me puedes pasar el ultimo trabajo porfa, es que no me a dado tiempo."}, + ] + self.actualizar_mensajes() + + # Reproductor de música + musica_frame = tk.Frame(self.frame, bg="lightgray", height=50) + musica_frame.grid(row=5, column=0, sticky="ew", padx=5, pady=5) + tk.Label(musica_frame, text="Reproductor música", bg="lightgray", font=("Helvetica", 10)).pack() + + # Botones de control de música + boton_play = tk.Button(musica_frame, text="Play", bg="green", fg="white", command=self.reproducir_musica_thread) + boton_play.pack(side="left", padx=5) + + boton_pause = tk.Button(musica_frame, text="Pause", bg="orange", fg="white", command=self.pausar_musica_thread) + boton_pause.pack(side="left", padx=5) + + boton_restart = tk.Button(musica_frame, text="Restart", bg="blue", fg="white", command=self.reiniciar_musica_thread) + boton_restart.pack(side="left", padx=5) + + self.frame.rowconfigure(4, weight=1) + + #Metodos para mensajes + def enviar_mensaje_thread(self): + """Inicia un hilo para agregar un mensaje.""" + threading.Thread(target=self.enviar_mensaje, daemon=True).start() + + def enviar_mensaje(self): + """Agrega un mensaje al listado.""" + texto = self.entrada_mensaje.get("1.0", tk.END).strip() + if texto: + self.mensajes.append({"alumno": "Tú", "texto": texto}) + self.entrada_mensaje.delete("1.0", tk.END) + self.actualizar_mensajes() + else: + messagebox.showwarning("Aviso", "El mensaje está vacío.") + + def actualizar_mensajes(self): + """Actualiza el listado de mensajes en la interfaz.""" + for widget in self.mensajes_frame.winfo_children(): + widget.destroy() + + for mensaje in self.mensajes: + tk.Label(self.mensajes_frame, text=mensaje["alumno"], font=("Helvetica", 10, "bold"), anchor="w").pack( + fill="x", padx=5, pady=2 + ) + tk.Label( + self.mensajes_frame, text=mensaje["texto"], font=("Helvetica", 9), anchor="w", wraplength=180, justify="left" + ).pack(fill="x", padx=5, pady=2) + + # Metodos para control de música + def reproducir_musica_thread(self): + """Inicia un hilo para reproducir música.""" + threading.Thread(target=self.reproducir_musica, daemon=True).start() + + def reproducir_musica(self): + """Reproduce una canción.""" + try: + pygame.mixer.music.load("cancion.mp3") + pygame.mixer.music.play() + messagebox.showinfo("Reproducción", "Reproduciendo canción.") + except pygame.error as e: + messagebox.showerror("Error", f"No se pudo reproducir la canción: {e}") + + def pausar_musica_thread(self): + """Inicia un hilo para pausar la música.""" + threading.Thread(target=self.pausar_musica, daemon=True).start() + + def pausar_musica(self): + """Pausa la música.""" + pygame.mixer.music.pause() + messagebox.showinfo("Reproducción", "Música en pausa.") + + def reiniciar_musica_thread(self): + """Inicia un hilo para reiniciar la música.""" + threading.Thread(target=self.reiniciar_musica, daemon=True).start() + + def reiniciar_musica(self): + """Reinicia la música desde el principio.""" + pygame.mixer.music.stop() + pygame.mixer.music.play() + messagebox.showinfo("Reproducción", "Reproduciendo desde el principio.") diff --git a/cancion.mp3 b/cancion.mp3 new file mode 100644 index 0000000..c76f8e0 Binary files /dev/null and b/cancion.mp3 differ diff --git a/main.py b/main.py index 5322588..071b751 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ from tkinter import Menu # Importar el widget Menu from tkinter import ttk # Importar el widget ttk from tkinter import messagebox from app import monitorization +from app import panel_derecho import threading import time import datetime @@ -71,6 +72,8 @@ frame_derecho.grid(row=0, column=2, sticky="ns") frame_izquierdo.grid_propagate(False) frame_derecho.grid_propagate(False) +panel_izquierdo = panel_derecho.PanelDerecho(frame_derecho) + # Dividir el frame central en dos partes (superior variable e inferior fija) frame_central.rowconfigure(0, weight=1) # Parte superior, tamaño variable frame_central.rowconfigure(1, weight=0) # Parte inferior, tamaño fijo