-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtodo-app-class.py
More file actions
40 lines (30 loc) · 1.04 KB
/
Copy pathtodo-app-class.py
File metadata and controls
40 lines (30 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import pglet
from pglet import Stack, Textbox, Button, Checkbox
class TodoApp:
def __init__(self):
self.new_task = Textbox(placeholder="Whats needs to be done?", width="100%")
self.tasks_view = Stack()
# application's root control (i.e. "view") containing all other controls
self.view = Stack(
width="70%",
controls=[
Stack(
horizontal=True,
on_submit=self.add_clicked,
controls=[self.new_task, Button("Add", on_click=self.add_clicked)],
),
self.tasks_view,
],
)
def add_clicked(self, e):
self.tasks_view.controls.append(Checkbox(label=self.new_task.value))
self.tasks_view.update()
def main(page):
page.title = "ToDo App"
page.horizontal_align = "center"
page.update()
# create application instance
app = TodoApp()
# add application's root control to the page
page.add(app.view)
pglet.app("todo-app", target=main)