[Python] How to get value from row in kivymd datatable using on_row_press() method

Discussão em 'Python' iniciado por Stack, Maio 30, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to get data from the row which I will press. But I didn't get any related data which is in my table. Here is my code

    from kivymd.app import MDApp
    from kivymd.uix.screen import Screen
    from kivy.metrics import dp
    from kivymd.uix.datatables import MDDataTable

    class Example(MDApp):
    def build(self):
    screen =Screen()
    table = MDDataTable(
    column_data=[('roll no',dp(15)),
    ('name',dp(30))],
    row_data=[(1,'Hasib'),
    (2,'shihab')])
    table.bind(on_row_press=self.row_press)
    screen.add_widget(table)
    return screen

    def row_press(self,instance_table,instance_row):
    print(instance_row)

    Example().run()


    I got this- <kivymd.uix.datatables.datatables.CellRow object at 0x0000020A467307B0>

    If I press any I wanted to get the roll and name. I read the kivymd docs but I didn't get my answer Please help me

    Continue reading...

Compartilhe esta Página