print the value selected in recycleview kivy

≯℡__Kan透↙ 提交于 2021-01-29 09:16:17

问题


I have a problem, when pressing on the list of the recyclerview i print the number of the index but i need print the value in the index code in below please any one can help me

class SecondWindow(BoxLayout,Screen):
    myresult = ListProperty([("N_matricule", "Operateur")])

    def insert_part(self):
        partnum = self.ids.Part_field
        part = partnum.text

        mycursor.execute(
            """SELECT OPERATION_DESCRIPTION FROM liste_des_operations WHERE PART_NO = %s""",
            (part,))
        self.myresult = mycursor.fetchall()
        #for row in myresult:
            #print(row)
            #print(type(row))
class RVItem(Factory.Button):
    def get_data_index(self, values):
        return self.parent.get_view_index_at(self.center)
    def on_press(self):
        print(self.get_data_index())

kv file

RecycleView:

    data: [{'text':"{}".format(OPERATION_DESCRIPTION)} for OPERATION_DESCRIPTION in root.myresult]
    viewclass: "RVItem"
    RecycleBoxLayout:
        default_size: None, dp(56)
        orientation: "vertical"
        default_size_hint: 1, None
        size_hint_y: None
        height: self.minimum_height
        key_selection: 'selectable'
        multiselect: True
        touch_multiselect: True

来源:https://stackoverflow.com/questions/61563477/print-the-value-selected-in-recycleview-kivy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!