I'm learning kivymd and I would like to create a MDList with an OneLineAvatarIconListItem that has two left icons. The docs only show how to do that with two right icons. This is my code (I changed "right" to "left" everywhere):
Taking a look at the source code I put together the ‘hack’ below. If I was going to put this into production, I think I would create a custom list item derived from BaseListItem.
from kivy.lang import Builder
from kivymd.app import MDApp
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.uix.list import ILeftBodyTouch
KV =
'''
OneLineAvatarIconListItem:
text: "One-line item with avatar"
on_size:
self.ids._left_container.width = container.width
self.ids._left_container.x = container.width
self._txt_left_pad = dp(100) # increase pad to make room
IconRightWidget:
icon: "cog"
YourContainer:
id: container
size_hint_x: None
width: self.minimum_width # size the BoxLayout
MDIconButton:
icon: "minus"
MDIconButton:
icon: "plus"
'''
class YourContainer(ILeftBodyTouch, MDBoxLayout):
adaptive_width = True
class Example(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
return Builder.load_string(KV)
Example().run()
The result:
I guess I have to do something more...
Also I would appreciate if you could write YourContainer into KV, I tried, but it didn't work.
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/94463a3c-26d0-4102-9f2f-42f6f25f95a5n%40googlegroups.com.