-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscratch.py
More file actions
51 lines (39 loc) · 1.23 KB
/
scratch.py
File metadata and controls
51 lines (39 loc) · 1.23 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
41
42
43
44
45
46
47
48
49
50
51
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivymd.uix.list import OneLineListItem
from kivymd.uix.button import MDRaisedButton
from kivymd.uix.textfield import MDTextField
KV = '''
BoxLayout:
orientation: 'vertical'
MDToolbar:
title: 'To-Do List'
left_action_items: [['menu', lambda x: app.callback()]]
ScrollView:
MDList:
id: todo_list
BoxLayout:
size_hint_y: None
height: "48dp"
MDTextField:
id: task_input
hint_text: "Enter task"
helper_text: "Press 'Enter' to add task"
on_text_validate: app.add_task()
MDRaisedButton:
text: "Add Task"
on_release: app.add_task()
'''
class TodoListApp(MDApp):
def build(self):
return Builder.load_string(KV)
def add_task(self):
task_text = self.root.ids.task_input.text
if task_text:
self.root.ids.todo_list.add_widget(OneLineListItem(text=task_text))
self.root.ids.task_input.text = ""
def callback(self):
print("Menu button pressed")
if __name__ == "__main__":
TodoListApp().run()