Python Forum

Full Version: [Kivy]RecyclevieW
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Good day,I am trying to fill a recycleview but get a mistake, tells me to increase greedView rows or columns. what am I doing wrong?

Python file:
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.screenmanager import Screen
from kivy.uix.popup import Popup


from gestioneDB import GestioneDB

# data
items = [{'number': '510001', 'name': 'Big Pump', 'size': '1.50 L', 'in_stock': True},
         {'number': '523001', 'name': 'Leonie Still', 'size': '1.60 L', 'in_stock': False},
         {'number': '641301', 'name': 'Apple Mix', 'size': '1.30 L', 'in_stock': True},
         {'number': '681301', 'name': 'Orange Mix', 'size': '1.40 L', 'in_stock': True}
        ]

class CaricoRipPopup(Popup):

    def add(self,descrizione, lavorazione):
        GestioneDB.insertDB(self,descrizione, lavorazione)
class MultiFieldLine(BoxLayout):
    # class layout defined in kv file
    pass
class GuiInsert(Screen,GridLayout):
    def __init__(self,**kwargs):
        super(GuiInsert, self).__init__(**kwargs)

        self.rv.data = [{'label_1': str(x['number']), 'label_2': str(x['name']), 'label_3': str(x['size']),
                         'checkbox_1': x['in_stock']} for x in items]


    def openCaricoRip(self):
        GestioneDB.connectDB(self)
        self.caricoRip = CaricoRipPopup()
        self.caricoRip.open()

    def caricadati(self):
        GestioneDB.readDB(self)
kv File

MultiFieldLine>:
    orientation: 'horizontal'
    label_1: ''
    label_2: ''
    label_3: ''
    checkbox_1: False
    Label:
        text: root.label_1
    Label:
        text: root.label_2
    Label:
        text: root.label_3
    CheckBox:
        active: root.checkbox_1
<GuiInsert>: # inherit from GridLayout
    rv: rv_id

    cols:  1
    rows: 2

    GridLayout: # col titles
        cols: 4
        rows: 1
        size_hint_y: 0.04
        Label:
            text: 'Number'
        Label:
            text: 'Name'
        Label:
            text: 'Size'
        Label
            text: 'In stock'
    GridLayout: # data
        cols: 1
        rows: 1
        size_hint_y: 0.96
        RecycleView:
            id: rv_id
            viewclass: 'GuiInsert'
            RecycleBoxLayout:
                default_size: None, dp(20)
                default_size_hint: 1, None
                size_hint_y: None
                height: self.minimum_height
                orientation: 'vertical'
error:

 raise GridLayoutException(
 kivy.uix.gridlayout.GridLayoutException: Too many children in GridLayout. Increase rows/cols!
I reply alone, it is wrong the data model I had to enter instead of viewclass:Guiinsert vviewclass: Multifieldline


(Aug-02-2021, 02:00 PM)nio74maz Wrote: [ -> ]Good day,I am trying to fill a recycleview but get a mistake, tells me to increase greedView rows or columns. what am I doing wrong?

Python file:
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.screenmanager import Screen
from kivy.uix.popup import Popup


from gestioneDB import GestioneDB

# data
items = [{'number': '510001', 'name': 'Big Pump', 'size': '1.50 L', 'in_stock': True},
         {'number': '523001', 'name': 'Leonie Still', 'size': '1.60 L', 'in_stock': False},
         {'number': '641301', 'name': 'Apple Mix', 'size': '1.30 L', 'in_stock': True},
         {'number': '681301', 'name': 'Orange Mix', 'size': '1.40 L', 'in_stock': True}
        ]

class CaricoRipPopup(Popup):

    def add(self,descrizione, lavorazione):
        GestioneDB.insertDB(self,descrizione, lavorazione)
class MultiFieldLine(BoxLayout):
    # class layout defined in kv file
    pass
class GuiInsert(Screen,GridLayout):
    def __init__(self,**kwargs):
        super(GuiInsert, self).__init__(**kwargs)

        self.rv.data = [{'label_1': str(x['number']), 'label_2': str(x['name']), 'label_3': str(x['size']),
                         'checkbox_1': x['in_stock']} for x in items]


    def openCaricoRip(self):
        GestioneDB.connectDB(self)
        self.caricoRip = CaricoRipPopup()
        self.caricoRip.open()

    def caricadati(self):
        GestioneDB.readDB(self)
kv File

MultiFieldLine>:
    orientation: 'horizontal'
    label_1: ''
    label_2: ''
    label_3: ''
    checkbox_1: False
    Label:
        text: root.label_1
    Label:
        text: root.label_2
    Label:
        text: root.label_3
    CheckBox:
        active: root.checkbox_1
<GuiInsert>: # inherit from GridLayout
    rv: rv_id

    cols:  1
    rows: 2

    GridLayout: # col titles
        cols: 4
        rows: 1
        size_hint_y: 0.04
        Label:
            text: 'Number'
        Label:
            text: 'Name'
        Label:
            text: 'Size'
        Label
            text: 'In stock'
    GridLayout: # data
        cols: 1
        rows: 1
        size_hint_y: 0.96
        RecycleView:
            id: rv_id
            viewclass: 'GuiInsert'
            RecycleBoxLayout:
                default_size: None, dp(20)
                default_size_hint: 1, None
                size_hint_y: None
                height: self.minimum_height
                orientation: 'vertical'
error:

 raise GridLayoutException(
 kivy.uix.gridlayout.GridLayoutException: Too many children in GridLayout. Increase rows/cols!