Skip to content

Instantly share code, notes, and snippets.

@tshirtman
Created March 23, 2021 22:09
Show Gist options
  • Save tshirtman/9c15c54a3962e834f5b9ab440a549d15 to your computer and use it in GitHub Desktop.
Save tshirtman/9c15c54a3962e834f5b9ab440a549d15 to your computer and use it in GitHub Desktop.
recycleview behind the scene
'''
'''
from kivy.app import App
from kivy.lang import Builder
KV = '''
#:import get_random_color kivy.utils.get_random_color
<-StencilView>:
# clear the stencilview rule to make scrollview/recycleview more understandable
# draw a line to still see the delimitations
canvas.after:
Color:
rgba: 1, 0, 0, .2
Line:
rectangle: self.pos + self.size
width: 5
<ColoredButton@Button>:
# create a colored button to see relayouts
background_color: get_random_color()
size_hint: None, None
FloatLayout:
RecycleView:
size_hint: .5, .5
pos_hint: {'center': (.5, .5)}
viewclass: 'ColoredButton'
data: [{'text': str(x)} for x in range(10000)]
RecycleGridLayout:
spacing: 10
cols: 100
rows: 100
size_hint: None, None
size: self.minimum_size
default_size_hint: None, None
default_size: 100, 100
'''
class Application(App):
def build(self):
return Builder.load_string(KV)
if __name__ == "__main__":
Application().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment