Python 如何在KivyMD中创建图像列表(numpy数组)?

Python 如何在KivyMD中创建图像列表(numpy数组)?,python,kivy,kivymd,Python,Kivy,Kivymd,我尝试使用MDList和add_widget()执行此操作,但出现了异常:AttributeError:'kivy.graphics.texture.texture'对象没有属性'fbind'。还有图像列表组件,但它的源代码必须是图像文件,而不是numpy数组。 KV文件: Python: frame = detection['frame'] texture = Texture.create(size=(frame.shape[1], frame.shape[0]), colorfmt='bgr

我尝试使用MDList和add_widget()执行此操作,但出现了异常:AttributeError:'kivy.graphics.texture.texture'对象没有属性'fbind'。还有图像列表组件,但它的源代码必须是图像文件,而不是numpy数组。 KV文件:

Python:

frame = detection['frame']
texture = Texture.create(size=(frame.shape[1], frame.shape[0]), colorfmt='bgr')
texture.blit_buffer(frame.tobytes(), colorfmt='bgr', bufferfmt='ubyte')
self.ids.detections_list.add_widget(texture)
KivyMD文档中的图像列表示例:

ScrollView:

MDGridLayout:
    cols: 3
    adaptive_height: True
    padding: dp(4), dp(4)
    spacing: dp(4)

    MyTile:
        source: "cat-1.jpg"
        text: "[size=26]Cat 1[/size]\n[size=14]cat-1.jpg[/size]"

    MyTile:
        source: "cat-2.jpg"
        text: "[size=26]Cat 2[/size]\n[size=14]cat-2.jpg[/size]"
        tile_text_color: app.theme_cls.accent_color

    MyTile:
        source: "cat-3.jpg"
        text: "[size=26][color=#ffffff]Cat 3[/color][/size]\n[size=14]cat-3.jpg[/size]"
        tile_text_color: app.theme_cls.accent_color

您只能使用
add_widget()
来添加小部件,
纹理
不是小部件。尝试使用该纹理创建一个
图像
,并添加该
图像
小部件而不是纹理。@JohnAnderson它可以工作!非常感谢。
ScrollView:

MDGridLayout:
    cols: 3
    adaptive_height: True
    padding: dp(4), dp(4)
    spacing: dp(4)

    MyTile:
        source: "cat-1.jpg"
        text: "[size=26]Cat 1[/size]\n[size=14]cat-1.jpg[/size]"

    MyTile:
        source: "cat-2.jpg"
        text: "[size=26]Cat 2[/size]\n[size=14]cat-2.jpg[/size]"
        tile_text_color: app.theme_cls.accent_color

    MyTile:
        source: "cat-3.jpg"
        text: "[size=26][color=#ffffff]Cat 3[/color][/size]\n[size=14]cat-3.jpg[/size]"
        tile_text_color: app.theme_cls.accent_color