I've created a demo application related to MDDataTable as suggested by the creators on the following page: [https://kivymd.readthedocs.io/en/latest/components/datatables/index.html]
However, for some reason, when I hover over a row, the application seems to detect the cursor about two rows below, as evidenced by the highlighting of that row. Interestingly, when I use 'checkbox,' it is checked correctly, and the information printed in the console is accurate. I need this functionality, but I'm unable to proceed with it in this way. Is there any way to correct this discrepancy so that the application recognizes what I'm selecting with the cursor? I'm also unable to use the options at the bottom, such as changing the page or selecting 'rows per page.'
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,
check=True,
column_data=[
("No.", dp(30)),
("Status", dp(30)),
("Signal Name", dp(60), self.sort_on_signal),
("Severity", dp(30)),
("Stage", dp(30)),
("Schedule", dp(30), self.sort_on_schedule),
("Team Lead", dp(30), self.sort_on_team),
],
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",
),
(
"5",
(
"checkbox-marked-circle",
[39 / 256, 174 / 256, 96 / 256, 1],
"Online",
),
"Sirius: prod independent account",
"Negligible",
"Triaged",
"22:06",
"Diane Okuma",
),
],
sorted_on="Schedule",
sorted_order="ASC",
elevation=2,
)
self.data_tables.bind(on_row_press=self.on_row_press)
self.data_tables.bind(on_check_press=self.on_check_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_table, instance_row)
def on_check_press(self, instance_table, current_row):
'''Called when the check box in the table row is checked.'''
print(instance_table, current_row)
# Sorting Methods:
# since the https://github.com/kivymd/KivyMD/pull/914 request, the
# sorting method requires you to sort out the indexes of each data value
# for the support of selections.
#
# The most common method to do this is with the use of the builtin function
# zip and enumerate, see the example below for more info.
#
# The result given by these funcitons must be a list in the format of
# [Indexes, Sorted_Row_Data]
def sort_on_signal(self, data):
return zip(*sorted(enumerate(data), key=lambda l: l[1][2]))
def sort_on_schedule(self, data):
return zip(
*sorted(
enumerate(data),
key=lambda l: sum(
[
int(l[1][-2].split(":")[0]) * 60,
int(l[1][-2].split(":")[1]),
]
),
)
)
def sort_on_team(self, data):
return zip(*sorted(enumerate(data), key=lambda l: l[1][-1]))
Example().run()
Mouse-cursor being detected in wrong place
I've tried reinstalling Kivy and KivyMD, clearing the cache, restarting everything but without success.
Kivy 2.2.1 kivymd @ master branch OS: Windows