Kivy/MD - 如何将图标放置在文本列表项(带有代码和图像)的右侧..?

Kivy/MD - How do I place an icon to the right of a text list item (with code and image) ..?

我想在文本列表项的右侧放置一个图标,但是下面的代码给我一个错误 AttributeError: 'super' object has no attribute '__getattr__' 在这一行:items.add_widget(icon)。 这是我想要的样子: List item with icon

这是我的代码。可以复制,运行原样。

from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivymd.app import MDApp
from kivymd.uix.button import MDFlatButton
from kivymd.uix.list import OneLineIconListItem, IconRightWidget, MDList
from kivymd.uix.dialog import MDDialog

KV = '''
<Content>
    orientation: "vertical"
    spacing: "12dp"
    size_hint_y: None
    height: "400dp"
    ScrollView:
        MDList:
            id: Mcontainer

MDFloatLayout:
'''
class Content(BoxLayout):
    pass

class Example(MDApp):
    
    def on_start(self):
    
        Mcontent=Content()
        for x in range(0,7):
            icon = IconRightWidget(icon="lock")
            items = OneLineIconListItem(text="This is a test")
            items.add_widget(icon)
            Mcontent.ids.Mcontainer.add_widget(items)
        
        self.MSetFileOptionsdialog = MDDialog(type="custom",content_cls=Mcontent,)
        
        self.MSetFileOptionsdialog.open()

    def build(self):
        return Builder.load_string(KV)

Example().run()
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout

from kivymd.app import MDApp
from kivymd.uix.list import OneLineAvatarIconListItem
from kivymd.uix.dialog import MDDialog

KV = '''
<Item>
    _txt_left_pad: "12dp"

    IconRightWidget:
        icon: root.icon


<Content>
    orientation: "vertical"
    spacing: "12dp"
    size_hint_y: None
    height: "400dp"

    ScrollView:

        MDList:
            id: Mcontainer

MDFloatLayout:
'''


class Item(OneLineAvatarIconListItem):
    icon = StringProperty()


class Content(BoxLayout):
    pass


class Example(MDApp):
    def on_start(self):
        Mcontent = Content()

        for x in range(0, 7):
            items = Item(text="This is a test", icon="lock")
            Mcontent.ids.Mcontainer.add_widget(items)

        self.MSetFileOptionsdialog = MDDialog(type="custom", content_cls=Mcontent)
        self.MSetFileOptionsdialog.open()

    def build(self):
        return Builder.load_string(KV)


Example().run()