Reputation: 157
I have a problem showing a list in kivy. I don't know how why don't show this two entries. I think is something about how i pass my data, do I have to specify the columns or how to display the information. Am I passing wrong the data needed in recycleView?
My code.
My interchange.kv
<Button>
color: .8,.9,0,1
font_size: 16
<LeLayaout>:
rows: 3
cols: 1
FloatLayout:
size_hint: 1,.05
Button:
text: 'Generate'
pos_hint: {'center_x':.5,"center_y":.5}
BoxLayout:
RecycleBoxLayout:
default_size: None, dp(56)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
FloatLayout:
size_hint: 1,.05
Button:
text: 'Add person'
pos_hint: {'x':0,'y':0}
size_hint:.5,1
Button:
text: 'Remove person'
pos_hint: {'x':.5,'y':0}
size_hint:.5,1
My main.py
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.recycleview import RecycleView
# Before windows creation let's fix a size
from kivy.config import Config
Config.set('graphics', 'width', '400')
Config.set('graphics', 'height', '600')
import json
class RV(RecycleView):
def __init__(self, **kwargs):
super(RV, self).__init__(**kwargs)
self.data = {"Hector": "[email protected]","Pancho": "[email protected]"}
class LeLayaout(GridLayout):
pass
class InterchangeApp(App):
def build(self):
return LeLayaout()
if __name__ == '__main__':
InterchangeApp().run()
Upvotes: 0
Views: 151
Reputation: 39082
Several problems with your code:
RV
class, but you never use itdata
that you define in the __init__()
method of the RV
class is a dictionary, but the data is expected to be a list of dictionaries. See documentation.viewclass
, but your keys are peoples names.viewclass
for the RV
.To fix this change the BoxLayout
in your kv
to RV
, and add a viewclass
:
RV:
viewclass: 'Label'
RecycleBoxLayout:
default_size: None, dp(56)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
Then change the data
keys to contain properties of the viewclass
:
class RV(RecycleView):
def __init__(self, **kwargs):
super(RV, self).__init__(**kwargs)
self.data = [{"text": "[email protected]"}, {"text": "[email protected]"}]
This may not be what you intended, but you can define your own viewclass
and give it any properties that you need, as well as defining how it will display those properties.
Upvotes: 1