Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit69f3971

Browse files
committed
move code from pylist.py to the example directly to make pylist reusable and show more of the example potential
1 parent0b5004f commit69f3971

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

‎pyscriptjs/examples/pylist.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,4 @@ def on_click(self, evt=None):
88
self.select('input').element.checked=self.data['done']
99

1010
classPyList(PyListTemplate):
11-
item_class=PyItem
12-
13-
defadd_task(*ags,**kws):
14-
# create a new dictionary representing the new task
15-
task= {"content":new_task_content.value,"done":False,"created_at":dt.now() }
16-
17-
# add a new task to the list and tell it to use the `content` key to show in the UI
18-
# and to use the key `done` to sync the task status with a checkbox element in the UI
19-
myList.add(task,labels=['content'],state_key="done")
20-
21-
# clear the inputbox element used to create the new task
22-
new_task_content.clear()
11+
item_class=PyItem

‎pyscriptjs/examples/todo-pylist.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@
1414
- /utils.py
1515
</py-env>
1616
<py-register-widgetsrc="/pylist.py"name="py-list"klass="PyList"></py-register-widget>
17+
18+
<py-script>
19+
def add_task(*ags, **kws):
20+
# create a new dictionary representing the new task
21+
task = { "content": new_task_content.value, "done": False, "created_at": dt.now() }
22+
23+
# add a new task to the list and tell it to use the `content` key to show in the UI
24+
# and to use the key `done` to sync the task status with a checkbox element in the UI
25+
myList.add(task, labels=['content'], state_key="done")
26+
27+
# clear the inputbox element used to create the new task
28+
new_task_content.clear()
29+
30+
</py-script>
1731
</head>
1832

1933
<body>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp