Skip to content

Instantly share code, notes, and snippets.

@CoutinhoElias
Created August 31, 2021 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CoutinhoElias/c4792027353cf48e40047f7555d2081f to your computer and use it in GitHub Desktop.
Save CoutinhoElias/c4792027353cf48e40047f7555d2081f to your computer and use it in GitHub Desktop.
RecycleView with png images.
#In my py file I have:
from kivy.lang import Builder
from kivy.uix.recycleview import RecycleView
from kivymd.uix.list import TwoLineIconListItem, TwoLineAvatarListItem
from kivy.properties import StringProperty
from kivymd.app import MDApp
class ItemImage(TwoLineAvatarListItem):
source = StringProperty()
class ScreenListItens(Screen):
def on_kv_post(self, base_widget):
p = Detalhe.select(Detalhe.dsdetalhe, Detalhe.cdprincipal) \
.order_by(Detalhe.cdprincipal)
for row in p.dicts():
self.ids.rv.data.append(
{
"viewclass": "ItemImage",
"source": './images/python.png',
"text": row['dsdetalhe'],
"secondary_text":"SEGUNDO TEXTO",
"callback": lambda x: x,
}
)
class AppDesktop(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def build(self):
return Builder.load_file('main.kv')
AppDesktop().run()
# In my kv file I have the following screen:
<ScreenListItens>:
name: "list_itens"
MDBoxLayout:
orientation: 'vertical'
spacing: dp(10)
padding: dp(63)
RecycleView:
id: rv
key_viewclass: 'viewclass'
key_size: 'height'
RecycleBoxLayout:
padding: dp(10)
default_size: None, dp(48)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
# If I don't use RecycleView the images appear beautifully.
# Why can't I show the images?
# Why do widgets get disorganized?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment