KivyMD: The example code when copy pasted and run fails

Description of the Bug

I copy pasted the example code from this site https://kivymd.readthedocs.io/en/latest/components/datatables/index.html

The code fails with exceptions(given below). What is satisfying is that the same error occurs for my own code when it uses MDDataTable. SO it is not something I am doing wrong

ValueError: TableRecycleGridLayout.orientation is set to an invalid option 'vertical'. Must be one of: ['lr-tb', 'tb-lr', 'rl-tb', 'tb-rl', 'lr-bt', 'bt-lr', 'rl-bt', 'bt-rl'] File "C:\Apps\Anaconda3\envs\mark2market\lib\site-packages\kivy\lang\builder.py", line 705, in _apply_rule setattr(widget_set, key, value) File "kivy\weakproxy.pyx", line 35, in kivy.weakproxy.WeakProxy.__setattr__ File "kivy\properties.pyx", line 498, in kivy.properties.Property.__set__ File "kivy\properties.pyx", line 542, in kivy.properties.Property.set File "kivy\properties.pyx", line 533, in kivy.properties.Property.set File "kivy\properties.pyx", line 1253, in kivy.properties.OptionProperty.check

#Code

from kivy.metrics import dp

from kivymd.app import MDApp
from kivymd.uix.datatables import MDDataTable


class Example(MDApp):
    def build(self):
        self.data_tables = MDDataTable(
            size_hint=(0.9, 0.6),
            use_pagination=True,
            check=True,
            column_data=[
                ("No.", dp(30)),
                ("Column 1", dp(30)),
                ("Column 2", dp(30)),
                ("Column 3", dp(30)),
                ("Column 4", dp(30)),
                ("Column 5", dp(30)),
            ],
            row_data=[
                (f"{i + 1}", "2.23", "3.65", "44.1", "0.45", "62.5")
                for i in range(50)
            ],
        )
        self.data_tables.bind(on_row_press=self.on_row_press)
        self.data_tables.bind(on_check_press=self.on_check_press)

    def on_start(self):
        self.data_tables.open()

    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)


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

### Versions

* OS:  Windows 10
* Python: 3.8
* Kivy: 2.0.0rc4
* KivyMD: 0.104.1

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

@rauf-asad Update KivyMD library from master branch

I will try to create a patch that will do this selectively based on the kivy version and if that works , will submit a PR

If you change the orientation in datatable.py for just the widget, it will work with kivy2.0.0.rc4

TableRecycleGridLayout:
        id: row_controller
        key_selection: "selectable"
        cols: root.total_col_headings
        cols_minimum: root.cols_minimum
        default_size: None, dp(52)
        default_size_hint: 1, None
        size_hint: None, None
        height: self.minimum_height
        width: self.minimum_width
        orientation: "lr-tb"
        multiselect: True
        touch_multiselect: True

![dt](https://user-images.githubusercontent.com/53440744/96958501-40c6c200-151b-11eb-8186-d1c5c0b7f59b.png)