KivyMD Datatables

514 views
Skip to first unread message

Hand Banana

unread,
Jul 9, 2021, 2:25:18 PM7/9/21
to Kivy users support
Hello,

Is there anyway to change the position of the Datatables? Changing 'pos_hint' does nothing and I tried the 'pos' property which just fails. 

Thanks

Dev femibadmus

unread,
Jul 9, 2021, 6:36:05 PM7/9/21
to kivy-...@googlegroups.com
Show ur code or screenshots

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/69484f4f-fffd-497b-8132-49a477595751n%40googlegroups.com.

Hand Banana

unread,
Jul 13, 2021, 2:37:23 PM7/13/21
to Kivy users support
kivy_datatables.PNG

Elliot Garbus

unread,
Jul 13, 2021, 3:07:34 PM7/13/21
to kivy-...@googlegroups.com

Here is an example that honors pos and size.  If you would like more help please attach an executable example, and explain how you want the widget positioned.

 

from kivy.metrics import dp
from kivymd.app import MDApp
from kivymd.uix.datatables import MDDataTable
from kivy.lang import Builder

kv =
"""
FloatLayout:

"""


class Example(MDApp):
   
def build(self):
       
return Builder.load_string(kv)

   
def on_start(self):
        data_tables = MDDataTable(
           
size_hint=(None, None),
           
size=(200,400),
           
pos=(10, 20),
           
column_data=[
                (
"Column 1", dp(20)),
                (
"Column 2", dp(30)),
                (
"Column 3", dp(50), self.sort_on_col_3),
                (
"Column 4", dp(30)),
                (
"Column 5", dp(30)),
                (
"Column 6", dp(30)),
                (
"Column 7", dp(30), self.sort_on_col_2),
            ],
           
row_data=[
               
# The number of elements must match the length
                # of the `column_data` list.
               
(
                   
"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",
                ),
            ],
        )
       
self.root.add_widget(data_tables)

   
def sort_on_col_3(self, data):
       
return zip(
            *
sorted(
               
enumerate(data),
               
key=lambda l: l[1][3]
            )
        )

   
def sort_on_col_2(self, data):
       
return zip(
            *
sorted(
               
enumerate(data),
               
key=lambda l: l[1][-1]
            )
        )

Example().run()
Reply all
Reply to author
Forward
0 new messages