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")

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

Add comment

Your email address will not be published. Required fields are marked *

John Elder