Add basic Codu framework

This commit is contained in:
2025-11-24 22:21:03 -05:00
commit ca237230e1
6 changed files with 1188 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.venv
.idea

14
Pipfile Normal file
View File

@@ -0,0 +1,14 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
textual = "*"
base64-random = "*"
[dev-packages]
textual-dev = "*"
[requires]
python_version = "3.14"

1111
Pipfile.lock generated Normal file

File diff suppressed because it is too large Load Diff

0
codupoc/__init__.py Normal file
View File

61
codupoc/codupoc.py Normal file
View File

@@ -0,0 +1,61 @@
from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widgets import Checkbox, Input, Header, Footer
from base64_random import gen_random_base64
class NewTodo(Input):
def on_input_submitted(self, event: Input.Submitted) -> None:
self.main_app.save_todo(event.value)
def __init__(self, main_app: Codupoc, *args, **kwargs):
super().__init__(*args, **kwargs)
self.main_app = main_app
class TodoItem(Checkbox):
def __init__(self, main_app: Codupoc, *args, **kwargs):
super().__init__(*args, **kwargs)
self.main_app = main_app
class Codupoc(App[None]):
CSS_PATH = "codupoc.tcss"
BINDINGS = [
("n", "new_todo", "Add a new Todo list item"),
]
def compose(self) -> ComposeResult:
yield Header()
yield VerticalScroll(id="list_items")
yield Footer()
def action_new_todo(self):
tinput = NewTodo(self, placeholder="What needs to be done?", id="newtodo")
scroller = self.query_one("#list_items")
scroller.mount(tinput)
tinput.focus()
def save_todo(self, value: str):
tinput = self.query_one("#newtodo")
tinput.remove()
todo = Checkbox(value)
scroller = self.query_one("#list_items")
scroller.mount(todo)
todo.scroll_visible()
todo.focus()
def insert_todo(self, title: str, scroller: VerticalScroll):
id = gen_random_base64(10)
self.todos[id] = { "title": title, "completed": False }
def __init__(self):
super().__init__()
self.todos = {}
if __name__ == "__main__":
app = Codupoc()
app.run()

0
codupoc/codupoc.tcss Normal file
View File