diff --git a/app/__pycache__/game.cpython-313.pyc b/app/__pycache__/game.cpython-313.pyc new file mode 100644 index 0000000..2d11aee Binary files /dev/null and b/app/__pycache__/game.cpython-313.pyc differ diff --git a/app/__pycache__/panel_izquierdo.cpython-313.pyc b/app/__pycache__/panel_izquierdo.cpython-313.pyc index a2a58ac..0d421d6 100644 Binary files a/app/__pycache__/panel_izquierdo.cpython-313.pyc and b/app/__pycache__/panel_izquierdo.cpython-313.pyc differ diff --git a/app/__pycache__/pomodoro.cpython-313.pyc b/app/__pycache__/pomodoro.cpython-313.pyc index 31f56c0..f846e30 100644 Binary files a/app/__pycache__/pomodoro.cpython-313.pyc and b/app/__pycache__/pomodoro.cpython-313.pyc differ diff --git a/app/__pycache__/scraping.cpython-313.pyc b/app/__pycache__/scraping.cpython-313.pyc index 1f8fcf7..c784a36 100644 Binary files a/app/__pycache__/scraping.cpython-313.pyc and b/app/__pycache__/scraping.cpython-313.pyc differ diff --git a/app/game.py b/app/game.py index e69de29..09750e0 100644 --- a/app/game.py +++ b/app/game.py @@ -0,0 +1,52 @@ +import threading +import tkinter as tk +import random +import time + +class HiloJuego: + def __init__(self, frame): + self.frame = frame + + self.score = 0 + self.running = False + + self.label_score = tk.Label(frame, text=f"Puntaje: {self.score}", font=("Arial", 16), bg="lightgray") + self.label_score.pack(pady=10) + + self.start_button = tk.Button(frame, text="Iniciar Juego", command=self.iniciar_juego) + self.start_button.pack(pady=5) + + self.target_button = tk.Button(frame, text="¡Click me!", state="disabled", command=self.incrementar_puntaje) + self.target_button.pack(pady=20) + + def iniciar_juego(self): + self.running = True + self.score = 0 + self.label_score.config(text=f"Puntaje: {self.score}") + self.start_button.config(state="disabled") + self.target_button.config(state="normal") + + # Hilo para mover el botón + self.hilo_movimiento = threading.Thread(target=self.mover_boton) + self.hilo_movimiento.daemon = True + self.hilo_movimiento.start() + + def mover_boton(self): + while self.running: + x = random.randint(50, self.frame.winfo_width() - 100) + y = random.randint(50, self.frame.winfo_height() - 100) + + self.target_button.place(x=x, y=y) + time.sleep(1) + + def incrementar_puntaje(self): + self.score += 1 + self.label_score.config(text=f"Puntaje: {self.score}") + + #Fin del juego + if self.score >= 10: + self.running = False + self.start_button.config(state="normal") + self.target_button.config(state="disabled") + self.target_button.place_forget() + self.label_score.config(text=f"¡Juego Terminado! Puntaje final: {self.score}") diff --git a/app/pomodoro.py b/app/pomodoro.py index 634a313..f4c7743 100644 --- a/app/pomodoro.py +++ b/app/pomodoro.py @@ -90,7 +90,8 @@ class PomodoroTimer: self.is_running = False self.remaining_time = self.work_time if not self.is_break else self.break_time self.update_timer_label() - self.progress["value"] = 0 + self.progress["value"] = 0 + self.progress["maximum"] = 100 def apply_settings(self): try: @@ -103,20 +104,23 @@ class PomodoroTimer: messagebox.showerror("Error", "Por favor, ingresa valores numéricos válidos.") def run_timer(self): + total_time = self.remaining_time # Guarda el tiempo total inicial while self.remaining_time > 0 and self.is_running: time.sleep(1) self.remaining_time -= 1 self.update_timer_label() - self.progress["value"] = (self.work_time if not self.is_break else self.break_time) - self.remaining_time + # Calcula el progreso como porcentaje + elapsed_time = total_time - self.remaining_time + progress_value = (elapsed_time / total_time) * 100 + self.progress["value"] = progress_value if self.remaining_time == 0 and self.is_running: self.is_running = False self.is_break = not self.is_break - # Actualizar el tiempo restante según la nueva fase self.remaining_time = self.break_time if self.is_break else self.work_time - self.progress["maximum"] = self.break_time if self.is_break else self.work_time # Actualiza el máximo + self.progress["maximum"] = 100 self.update_timer_label() - self.progress["value"] = 0 # Reinicia la barra + self.progress["value"] = 0 messagebox.showinfo( "Pomodoro Finalizado", "¡Tiempo de descanso!" if self.is_break else "¡Tiempo de trabajar!", @@ -125,6 +129,7 @@ class PomodoroTimer: self.start_timer() + def update_timer_label(self): self.timer_label.config(text=self.format_time(self.remaining_time)) diff --git a/main.py b/main.py index e50504f..8a9f15f 100644 --- a/main.py +++ b/main.py @@ -11,6 +11,7 @@ import time import datetime import psutil from app import scraping +from app import game def update_time(status_bar): @@ -115,6 +116,9 @@ for i in range(1, 6): pomodoro.PomodoroTimer(tab) elif i == 3: notebook.add(tab, text="Gestor de tareas", padding=4) + elif i == 4: + notebook.add(tab,text='Juego', padding=4) + hilo_juego = game.HiloJuego(tab) else: notebook.add(tab, text=f"Solapa {i}", padding=4) # Añadir un Label en cada solapa para diferenciarla