KivyMD is a collection of Material Design compliant widgets for use with Kivy, a framework for cross-platform, touch-enabled graphical applications. https://youtube.com/c/KivyMD https://twitter.com/KivyMD https://habr.com/ru/users/kivymd https://stackoverflow.com/tags/kivymd
Are there anything special with MDListItem that prevent me from subclassing it? I try to create a custom MDListItem to configure the height, md_bg_color and other property, it's working when defined on the MDListItem, but not when creating a subclass.
from kivy.lang import Builder
from kivymd.app import MDApp
from kivy.utils import get_color_from_hex
from kivymd.uix.list import MDListItem
KV = '''
<MyListItem>:
height: "100dp"
padding: "0dp"
spacing: "0dp"
MDScreen:
md_bg_color: app.theme_cls.surfaceColor
MDBoxLayout:
orientation: 'vertical'
MDList:
MyListItem:
MDListItemHeadlineText:
text: "My Custom Item 1"
MDListItemTrailingIcon:
icon: "play"
MyListItem:
MDListItemHeadlineText:
text: "My Custom Item 2"
MDListItemTrailingIcon:
icon: "chevron-right"
MyListItem:
MDListItemHeadlineText:
text: "My Custom Item 3"
MDListItemTrailingIcon:
icon: "chevron-right"
MyListItem:
height: "100dp"
padding: "0dp"
spacing: "0dp"
MDListItemHeadlineText:
text: "My Custom Item 3"
MDListItemTrailingIcon:
icon: "chevron-right"
'''
class MyListItem(MDListItem):
pass
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
Example().run()
Are there anything special with MDListItem that prevent me from subclassing it? I try to create a custom MDListItem to configure the height, md_bg_color and other property, it's working when defined on the MDListItem, but not when creating a subclass.
The issue is here - https://github.com/kivymd/KivyMD/blob/master/kivymd/uix/list/list.kv#L43