在kivymd threelineiconitem中获取文本

时间:2020-11-02 08:03:10

标签: python kivymd

在发布此问题之前,我进行了搜索,但没有发现类似的问题,因为在标题中,我希望每次单击都检索mdlist的文本。我尝试了各种方法,但没有给我带来任何好处。这是我的代码: Kv.kv

                  RecycleView:
                            id: rv
                            key_viewclass: 'viewclass'
                            key_size: 'height'

                            RecycleBoxLayout:
                                padding: dp(10)
                                default_size: None, dp(90)
                                default_size_hint: 1, None
                                size_hint_y: None
                                height: self.minimum_height
                                orientation: 'vertical'

file.py

def data(self,widget,text,search=False):
    self.connection()
    result=self.c.execute("SELECT matricule,nom,classe FROM etudiant")
    def add_icon_item(name1,name2,name3):
        widget.data.append(
            {
                "viewclass": "CustomOneLineIconListItem",
                "icon": "account",
                "text": name1,
                "secondary_text":name2,
                "tertiary_text":name3,
                "callback": lambda x: x,
                "on_release": print(x.text)
            }
        )
    widget.data = []
    for row in result:
        if search:
            if text in row[0] or text in row[1] or text in row[2]:
                add_icon_item(row[1],row[0],row[2])
        else:
            add_icon_item(row[1],row[0],row[2])
    self.conn.close()

0 个答案:

没有答案