In this video I’ll show you how to create lists with KivyMD.
We’ll look at: OneLineListItem, TwoLineListItem, and ThreeLineListItem
Those allow you to create lists with one lined items, two lined items, or three lined items.
We’ll also look at how to do something whenever you click on an item in the list.
#kivy #codemy
Python Code: lists.py
GitHub Code: lists.py
from kivy.lang import Builder from kivymd.app import MDApp class MainApp(MDApp): title = "Simple List" def build(self): self.theme_cls.theme_style = "Dark" self.theme_cls.primary_palette = "BlueGray" return Builder.load_file('lists.kv') def presser(self, pressed, list_id): pressed.tertiary_text = f"You Pressed {list_id}" MainApp().run()
Kivy Design Code: lists.kv
GitHub Code: lists.kv
ScrollView: MDList: #OneLineListItem: #TwoLineListItem: ThreeLineListItem: id: item1 text: "Awesome List Item #1" secondary_text: "Second Line" tertiary_text: "Third Line" on_release: app.presser(self, "item1") ThreeLineListItem: id: item2 text: "Awesome List Item #2" secondary_text: "Second Line" tertiary_text: "Third Line" on_release: app.presser(self, "item2")
Add comment