10000 move code from pylist.py to the example directly by fpliger · Pull Request #37 · pyscript/pyscript · GitHub
[go: up one dir, main page]

Skip to content

move code from pylist.py to the example directly #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions pyscriptjs/examples/pylist.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,3 @@ def on_click(self, evt=None):

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()
14 changes: 14 additions & 0 deletions pyscriptjs/examples/todo-pylist.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
- /utils.py
</py-env>
<py-register-widget src="/pylist.py" name="py-list" klass="PyList"></py-register-widget>

<py-script>
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()

</py-script>
</head>

<body>
Expand Down
0