To do list
This commit is contained in:
parent
9abdca650c
commit
d03d7a4a3d
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -34,7 +34,7 @@ def actualizar_grafico_criptomonedas_api(canvas, ax):
|
||||||
canvas.draw()
|
canvas.draw()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error al obtener datos de criptomonedas: {e}")
|
print(f"Error al obtener datos de criptomonedas: {e}")
|
||||||
time.sleep(10) # Actualizar cada 10 segundos
|
time.sleep(60)
|
||||||
|
|
||||||
|
|
||||||
def actualizar_grafico_ibex_api(canvas, ax):
|
def actualizar_grafico_ibex_api(canvas, ax):
|
||||||
|
@ -59,7 +59,7 @@ def actualizar_grafico_ibex_api(canvas, ax):
|
||||||
canvas.draw()
|
canvas.draw()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error al obtener datos del IBEX: {e}")
|
print(f"Error al obtener datos del IBEX: {e}")
|
||||||
time.sleep(300) # Actualizar cada 5 minutos
|
time.sleep(60) # Actualizar cada 5 minutos
|
||||||
|
|
||||||
|
|
||||||
def iniciar_hilos(canvas_cripto, ax_cripto, canvas_ibex, ax_ibex):
|
def iniciar_hilos(canvas_cripto, ax_cripto, canvas_ibex, ax_ibex):
|
||||||
|
|
|
@ -96,7 +96,7 @@ class PanelIzquierdo:
|
||||||
def fetch_news():
|
def fetch_news():
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
url = 'https://newsapi.org/v2/top-headlines?country=us&apiKey=b1ea42563bd848499ebad866eeedaf15'
|
url = 'https://newsapi.org/v2/top-headlines?country=us&apiKey=bc352d5c21cf4ebcbbcf780f4a4b78d9'
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
import tkinter as tk
|
||||||
|
import threading
|
||||||
|
|
||||||
|
def actualizar_todo_list(todo_listbox, tareas):
|
||||||
|
"""Actualizar el contenido del ListBox con las tareas actuales."""
|
||||||
|
todo_listbox.delete(0, tk.END)
|
||||||
|
for tarea, completada in tareas:
|
||||||
|
estado = "[X]" if completada else "[ ]"
|
||||||
|
todo_listbox.insert(tk.END, f"{estado} {tarea}")
|
||||||
|
|
||||||
|
def agregar_tarea(entry, todo_listbox, tareas):
|
||||||
|
"""Agregar una nueva tarea a la lista."""
|
||||||
|
nueva_tarea = entry.get()
|
||||||
|
if nueva_tarea.strip():
|
||||||
|
tareas.append((nueva_tarea, False)) # Agregar tarea como no completada
|
||||||
|
actualizar_todo_list(todo_listbox, tareas)
|
||||||
|
entry.delete(0, tk.END)
|
||||||
|
|
||||||
|
def eliminar_tarea(todo_listbox, tareas):
|
||||||
|
"""Eliminar la tarea seleccionada de la lista."""
|
||||||
|
seleccion = todo_listbox.curselection()
|
||||||
|
if seleccion:
|
||||||
|
indice = seleccion[0]
|
||||||
|
tareas.pop(indice)
|
||||||
|
actualizar_todo_list(todo_listbox, tareas)
|
||||||
|
|
||||||
|
def marcar_tarea(todo_listbox, tareas):
|
||||||
|
"""Marcar la tarea seleccionada como completada o no completada."""
|
||||||
|
seleccion = todo_listbox.curselection()
|
||||||
|
if seleccion:
|
||||||
|
indice = seleccion[0]
|
||||||
|
tarea, completada = tareas[indice]
|
||||||
|
tareas[indice] = (tarea, not completada) # Alternar el estado de completada
|
||||||
|
actualizar_todo_list(todo_listbox, tareas)
|
||||||
|
|
||||||
|
def crear_solapa_todo(tab):
|
||||||
|
"""Función para inicializar la funcionalidad de la lista To-Do en la solapa."""
|
||||||
|
tareas = [] # Lista para almacenar las tareas
|
||||||
|
|
||||||
|
# Entry para agregar nuevas tareas
|
||||||
|
entry = tk.Entry(tab, font=("Arial", 12))
|
||||||
|
entry.pack(pady=10, padx=10, fill="x")
|
||||||
|
|
||||||
|
# Botón para agregar tareas
|
||||||
|
boton_agregar = tk.Button(tab, text="Agregar", command=lambda: agregar_tarea(entry, todo_listbox, tareas))
|
||||||
|
boton_agregar.pack(pady=5)
|
||||||
|
|
||||||
|
# ListBox para mostrar las tareas
|
||||||
|
todo_listbox = tk.Listbox(tab, font=("Arial", 12), height=10)
|
||||||
|
todo_listbox.pack(pady=10, padx=10, fill="both", expand=True)
|
||||||
|
|
||||||
|
# Botón para eliminar tareas
|
||||||
|
boton_eliminar = tk.Button(tab, text="Eliminar", command=lambda: eliminar_tarea(todo_listbox, tareas))
|
||||||
|
boton_eliminar.pack(pady=5)
|
||||||
|
|
||||||
|
# Botón para marcar tareas como completadas o no completadas
|
||||||
|
boton_marcar = tk.Button(tab, text="Marcar como hecho/no hecho", command=lambda: marcar_tarea(todo_listbox, tareas))
|
||||||
|
boton_marcar.pack(pady=5)
|
||||||
|
|
||||||
|
# Inicializar la lista vacía
|
||||||
|
actualizar_todo_list(todo_listbox, tareas)
|
5
main.py
5
main.py
|
@ -17,6 +17,7 @@ from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import random
|
import random
|
||||||
from app import graphics
|
from app import graphics
|
||||||
|
from app import todo_list
|
||||||
|
|
||||||
def update_time(status_bar):
|
def update_time(status_bar):
|
||||||
while True:
|
while True:
|
||||||
|
@ -130,6 +131,10 @@ for i in range(1, 6):
|
||||||
game_frame = tk.Frame(tab)
|
game_frame = tk.Frame(tab)
|
||||||
game_frame.pack(fill="both", expand=True)
|
game_frame.pack(fill="both", expand=True)
|
||||||
hilo_juego = game.HiloJuego(game_frame)
|
hilo_juego = game.HiloJuego(game_frame)
|
||||||
|
elif i == 5:
|
||||||
|
notebook.add(tab, text='To Do List', padding=4)
|
||||||
|
todo_list.crear_solapa_todo(tab)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
notebook.add(tab, text=f"Solapa {i}", padding=4)
|
notebook.add(tab, text=f"Solapa {i}", padding=4)
|
||||||
# Añadir un Label en cada solapa para diferenciarla
|
# Añadir un Label en cada solapa para diferenciarla
|
||||||
|
|
Loading…
Reference in New Issue