From 69f39713e018f283f3cdf4c79bc0772cea562773 Mon Sep 17 00:00:00 2001 From: Fabio Pliger Date: Wed, 20 Apr 2022 20:53:31 -0500 Subject: [PATCH 1/2] move code from pylist.py to the example directly to make pylist reusable and show more of the example potential --- pyscriptjs/examples/pylist.py | 13 +------------ pyscriptjs/examples/todo-pylist.html | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/pyscriptjs/examples/pylist.py b/pyscriptjs/examples/pylist.py index 0dfa781..d078549 100644 --- a/pyscriptjs/examples/pylist.py +++ b/pyscriptjs/examples/pylist.py @@ -8,15 +8,4 @@ class PyItem(PyItemTemplate): self.select('input').element.checked = self.data['done'] class PyList(PyListTemplate): - item_class = PyItem - -def add_task(*ags, **kws): - # create a new dictionary representing the new task - task = { "content": new_task_content.value, "done": False, "created_at": dt.now() } - - # add a new task to the list and tell it to use the `content` key to show in the UI - # and to use the key `done` to sync the task status with a checkbox element in the UI - myList.add(task, labels=['content'], state_key="done") - - # clear the inputbox element used to create the new task - new_task_content.clear() + item_class = PyItem \ No newline at end of file diff --git a/pyscriptjs/examples/todo-pylist.html b/pyscriptjs/examples/todo-pylist.html index 49c02b1..ae76ff3 100644 --- a/pyscriptjs/examples/todo-pylist.html +++ b/pyscriptjs/examples/todo-pylist.html @@ -14,6 +14,20 @@ - /utils.py + + + def add_task(*ags, **kws): + # create a new dictionary representing the new task + task = { "content": new_task_content.value, "done": False, "created_at": dt.now() } + + # add a new task to the list and tell it to use the `content` key to show in the UI + # and to use the key `done` to sync the task status with a checkbox element in the UI + myList.add(task, labels=['content'], state_key="done") + + # clear the inputbox element used to create the new task + new_task_content.clear() + + From 08aadbe2486de49dea916ec8f1726b51548e62a1 Mon Sep 17 00:00:00 2001 From: Fabio Pliger Date: Wed, 20 Apr 2022 20:54:28 -0500 Subject: [PATCH 2/2] add line at eof --- pyscriptjs/examples/pylist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyscriptjs/examples/pylist.py b/pyscriptjs/examples/pylist.py index d078549..78a22aa 100644 --- a/pyscriptjs/examples/pylist.py +++ b/pyscriptjs/examples/pylist.py @@ -8,4 +8,4 @@ class PyItem(PyItemTemplate): self.select('input').element.checked = self.data['done'] class PyList(PyListTemplate): - item_class = PyItem \ No newline at end of file + item_class = PyItem