kivy recycleview with line with multiple items

Asked

Viewed 126 times

0

How to make a recycleview with multiple items in a row? The examples I studied using Recyclegridlayout the columns become independent and so does not look good.

An example of how I wanted to do:

inserir a descrição da imagem aqui

1 answer

0

Here is an example table with 4 columns.

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.recycleview import RecycleView
from kivy.uix.boxlayout import BoxLayout

items = [
    {'1': 'Nome', '2': 'Telefone', '3': 'Cidade', '4': 'N. Pedido'},
    {'1': 'Paulo Souza', '2': '(81) 988754-8855', '3': 'Petrolina', '4': ''},
]


class Tabela(BoxLayout):
    pass


Builder.load_string('''
<Tabela>:
    orientation: 'horizontal'
    col1: 'column1'
    col2: 'column2'
    col3: 'column3'
    col4: 'column4'
    Label:
        id: label1
        text: root.col1
    Label:
        id: label2
        text: root.col2
    Label:
        id: label3
        text: root.col3
    Label:
        id: label4
        text: root.col4

<RV>:
    viewclass: 'Tabela'
    RecycleBoxLayout:
        default_size: None, dp(20)
        default_size_hint: 1, None
        size_hint_y: None
        height: self.minimum_height
        orientation: 'vertical'
''')


class RV(RecycleView):
    def __init__(self, **kwargs):
        super(RV, self).__init__(**kwargs)
        self.data = [{'col1': str(x['1']), 'col2': str(x['2']), 'col3': str(x['3']), 'col4': str(x['4'])} for x in items]


class TestApp(App):
    def build(self):
        return RV()


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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.