I have a database on Firebase of Google working well, I can save my data there easily. I would like to return this data for my app, but before I have problems with this, I can't list anything on Kivy.
I would want to use the ListView of Kivy, but in the documentation is recommended to use the RecycleView. But I can't understand the documentation. I have some doubts.
If you can read the docs of RecycleView, you'll see this as an example:
Builder.load_string('''
<RV>:
viewclass: 'Label'
RecycleBoxLayout:
default_size: None, dp(56)
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 = [{'text': str(x)} for x in range(100)]
class TestApp(App):
def build(self):
return RV()
if __name__ == '__main__':
TestApp().run()
But I'm using the ScreenManager to control my screens, then, in the TestApp class I return 'sm', like this example of the documentation:
# Declare both screens
class MenuScreen(Screen):
pass
class SettingsScreen(Screen):
pass
# Create the screen manager
sm = ScreenManager()
sm.add_widget(MenuScreen(name='menu'))
sm.add_widget(SettingsScreen(name='settings'))
class TestApp(App):
def build(self):
return sm
if __name__ == '__main__':
TestApp().run()
If you see the syntaxes are different, and it's here where I don't know how to code this. I would like to keep using the ScreenManager to control the screens and use a RecycleView to return my data in a list.
How can I use the RecycleView with my ScreenManager? This is my main.py, I configure the screen in another document, and I use the ki language too. So if you all can to do an example to me I will be grateful.
import kivy
from kivy.app import App, Builder
from kivy.config import Config
from kivy.uix.screenmanager import ScreenManager
from telas.telas import Acesso, Comprando, Vendendo, CadastrarEvento
kivy.require('1.10.1')
Builder.load_file('ing.kv')
Config.read('config.ini')
sm = ScreenManager()
sm.add_widget(Acesso(name='acesso'))
sm.add_widget(Comprando(name='comprando'))
sm.add_widget(Vendendo(name='vendendo'))
sm.add_widget(CadastrarEvento(name='cadastrarEvento'))
sm.add_widget(ListaEventos(name='listaEventos'))
class IngApp(App):
def build(self):
return sm
if __name__ == '__main__':
IngApp().run()
Here the kv that I tried the first time
<ListaEventos>:
canvas:
Rectangle:
source: 'design/fundo.png'
size: self.width, self.height
viewclass: 'Label'
RecycleBoxLayout:
default_size: None, dp(56)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
ListaEventos:
class ListaEvento(Screen, RecycleView):
def __init__(self, **kwargs):
super(ListaEvento, self).__init__(**kwargs)
self.data = [{'text': str(x)} for x in range(20)]