From 270ec59fbefd8271255a26e892b49a7db82d0f8d Mon Sep 17 00:00:00 2001 From: Andrew Luchuk Date: Tue, 25 Nov 2025 23:17:24 -0500 Subject: [PATCH] Begin integrating manager into main app --- codupoc/codupoc.py | 11 +++++++---- codupoc/todomanager.py | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/codupoc/codupoc.py b/codupoc/codupoc.py index 8e28e54..3a9775a 100644 --- a/codupoc/codupoc.py +++ b/codupoc/codupoc.py @@ -4,6 +4,8 @@ from textual.widgets import Checkbox, Input, Header, Footer from base64_random import gen_random_base64 +from todo import Todo + class NewTodo(Input): def on_input_submitted(self, event: Input.Submitted) -> None: self.main_app.save_todo(event.value) @@ -14,9 +16,10 @@ class NewTodo(Input): class TodoItem(Checkbox): - def __init__(self, main_app: Codupoc, *args, **kwargs): + def __init__(self, main_app: Codupoc, todo: Todo, *args, **kwargs): super().__init__(*args, **kwargs) self.main_app = main_app + self.todo = todo class Codupoc(App[None]): @@ -47,9 +50,9 @@ class Codupoc(App[None]): todo.focus() def insert_todo(self, title: str, scroller: VerticalScroll): - todo_id = gen_random_base64(10) - self.todos[todo_id] = { "title": title, "completed": False } - todo = TodoItem(self, title, id=todo_id) + ntodo = Todo(title, False) + self.todos[ntodo.lid] = ntodo + todo = TodoItem(self, ntodo, title, id=ntodo.lid) scroller.mount(todo) todo.focus() diff --git a/codupoc/todomanager.py b/codupoc/todomanager.py index 051277b..8b95a3d 100644 --- a/codupoc/todomanager.py +++ b/codupoc/todomanager.py @@ -24,4 +24,7 @@ class TodoManager: for line in f: todos.append(parse_todo(line)) - return todos \ No newline at end of file + return todos + + def close_todo_file(self): + self.file.close() \ No newline at end of file