MCPcopy Index your code
hub / github.com/flet-dev/flet / Task

Class Task

sdk/python/examples/tutorials/todo/step_4.py:8–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7@ft.control
8class Task(ft.Column):
9 task_name: str = ""
10 on_task_delete: Callable[["Task"], None] = field(default=lambda task: None)
11
12 def init(self):
13 self.display_task = ft.Checkbox(value=False, label=self.task_name)
14 self.edit_name = ft.TextField(expand=1)
15
16 self.display_view = ft.Row(
17 alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
18 vertical_alignment=ft.CrossAxisAlignment.CENTER,
19 controls=[
20 self.display_task,
21 ft.Row(
22 spacing=0,
23 controls=[
24 ft.IconButton(
25 icon=ft.Icons.CREATE_OUTLINED,
26 tooltip="Edit To-Do",
27 on_click=self.edit_clicked,
28 ),
29 ft.IconButton(
30 ft.Icons.DELETE_OUTLINE,
31 tooltip="Delete To-Do",
32 on_click=self.delete_clicked,
33 ),
34 ],
35 ),
36 ],
37 )
38
39 self.edit_view = ft.Row(
40 visible=False,
41 alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
42 vertical_alignment=ft.CrossAxisAlignment.CENTER,
43 controls=[
44 self.edit_name,
45 ft.IconButton(
46 icon=ft.Icons.DONE_OUTLINE_OUTLINED,
47 icon_color=ft.Colors.GREEN,
48 tooltip="Update To-Do",
49 on_click=self.save_clicked,
50 ),
51 ],
52 )
53 self.controls = [self.display_view, self.edit_view]
54
55 def edit_clicked(self, e):
56 self.edit_name.value = self.display_task.label
57 self.display_view.visible = False
58 self.edit_view.visible = True
59 self.update()
60
61 def save_clicked(self, e):
62 self.display_task.label = self.edit_name.value
63 self.display_view.visible = True
64 self.edit_view.visible = False
65 self.update()

Callers 1

add_clickedMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected