import kandinsky as kd # Définition d'une liste pour stocker les tâches taches = [] # Fonction pour ajouter une tâche à la liste def ajouter_tache(tache): taches.append(tache) # Fonction pour afficher la liste des tâches def afficher_taches(): kd.clear() kd.draw_string(10, 10, "Liste des tâches:", (0, 0, 0)) y = 30 for i, tache in enumerate(taches, start=1): kd.draw_string(10, y, "{}. {}".format(i, tache), (0, 0, 0)) y += 20 kd.display() # Fonction pour supprimer une tâche de la liste def supprimer_tache(choix): if 1 <= choix <= len(taches): tache_supprimee = taches.pop(choix - 1) return "Tâche '{}' supprimée avec succès.".format(tache_supprimee) else: return "Numéro de tâche invalide." # Boucle principale while True: kd.fill_rect(0, 0, 320, 240, (255, 255, 255)) kd.draw_string(10, 10, "Gestionnaire de tâches", (0, 0, 0)) kd.draw_string(10, 30, "1. Ajouter une tâche", (0, 0, 0)) kd.draw_string(10, 50, "2. Afficher les tâches", (0, 0, 0)) kd.draw_string(10, 70, "3. Supprimer une tâche", (0, 0, 0) kd.draw_string(10, 90, "4. Quitter", (0, 0, 0)) kd.display() choix = int(input()) if choix == 1: tache = input("Entrez la tâche à ajouter : ") ajouter_tache(tache) elif choix == 2: afficher_taches() elif choix == 3: num_tache = int(input("Entrez le numéro de la tâche à supprimer : ")) message = supprimer_tache(num_tache) kd.draw_string(10, 200, message, (0, 0, 0)) kd.display() kd.wait(1000) elif choix == 4: break else: kd.draw_string(10, 200, "Opération non valide.", (0, 0, 0)) kd.display() kd.wait(1000)