KivyMD icon indicating copy to clipboard operation
KivyMD copied to clipboard

KivyMD/MDDataTable passing a row to a dropdown menu when right-clicking on a row in a table

Open GreenStalk opened this issue 2 years ago • 1 comments

Description of the Feature

KivyMD/MDDataTable capassing a row to a dropdown menu when right-clicking on a row in a table

Code and Logs

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

class Example(MDApp):
    def build(self):
        self.data_tables = MDDataTable(
            use_pagination=True,
            column_data=[
                ("No.", dp(30)),
                ("Status", dp(30)),
                ("Signal Name", dp(60)),
                ("Severity", dp(30)),
                ("Stage", dp(30)),
                ("Schedule", dp(30)),
                ("Team Lead", dp(30)),
            ],
            row_data=[
                ("1",
                ("alert", [255 / 256, 165 / 256, 0, 1], "No Signal"),
                "Astrid: NE shared managed",
                "Medium",
                "Triaged",
                "0:33",
                "Chase Nguyen",),
                ("2",
                
                ("alert-circle", [1, 0, 0, 1], "Offline"),
                "Cosmo: prod shared ares",
                "Huge",
                "Triaged",
                "0:39",
                "Brie Furman",),
                
                ("3",
                ("checkbox-marked-circle", [39 / 256, 174 / 256, 96 / 256, 1], "Online",),
                "Phoenix: prod shared lyra-lists",
                "Minor",
                "Not Triaged",
                "3:12",
                "Jeremy lake",),
                
                ("4",
                ("checkbox-marked-circle",[39 / 256, 174 / 256, 96 / 256, 1],"Online",),
                "Sirius: NW prod shared locations",
                "Negligible",
                "Triaged",
                "13:18",
                "Angelica Howards",),
            ],
        )
        self.data_tables.bind(on_row_press=self.on_row_press)

        screen = MDScreen()
        screen.add_widget(self.data_tables)
        return screen

    def on_row_press(self, instance_table, instance_row):
        '''Called when a table row is clicked.'''
        print(instance_row)


Example().run()
"""


class MainApp(App):
    def build(self):
        self.root = Builder.load_string(kv)


if __name__ == '__main__':
    MainApp().run()

Versions

  • OS: Windows 8.1
  • Python: 3.9.5
  • Kivy: 2.1.0
  • KivyMD: 1.0.0.dev

GreenStalk avatar Aug 22 '22 07:08 GreenStalk

@GreenStalk I'm sorry, but I don't understand the essence of your issue.

HeaTTheatR avatar Aug 22 '22 09:08 HeaTTheatR